On Thu, Oct 31, 2002 at 11:51:09AM -0500, Joe Rioux wrote:
> I have two followup questions relative to this.
> 1) Someone mentioned that I really shouldn't simply
>    run the copy command through a system call, but
>    instead use something akin to system("cmd.exe copy ...")
>    since copy is internal to it.  I asked him why but 
>    didn't get a response.  I assumed, perhaps incorrectly,
>    that a system() call inherits the shell of the parent
>    process and would therefore simply run the internal
>    copy command for cmd.exe.
>    Does anyone know why he said I shouldn't do this?

system(SCALAR_ARG) ends up running "cmd.exe /x/c SCALAR_ARG" on
>=WINNT and "command.com /c SCALAR_ARG" on <WINNT. Specifying cmd.exe
would be like calling "cmd.exe /x/c cmd.exe ...". This is the same on
Unix, in that system(SCALAR_ARG) on UNIx runs "/bin/sh -c
'SCALAR_ARG'". The same thing applies - specifying /bin/sh explicitly
would be like calling "/bin/sh -c '/bin/sh -c \'SCALAR_ARG\''". It
will work, but is is unnecessary.

The person who suggested that you need to specify cmd.exe
may not have been aware of this.

> 2) Perhaps it would be better for me to issue the
>    copy command then rather than check the exit
>    code use the -f operator to see if the resulting
>    file exists.  Does that seem reasonable?

It would be better to use File::Copy and not rely on external non-portable
commands.

mark

-- 
[EMAIL PROTECTED][EMAIL PROTECTED][EMAIL PROTECTED] __________________________
.  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Neighbourhood Coder
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | 
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, Ontario, Canada

  One ring to rule them all, one ring to find them, one ring to bring them all
                       and in the darkness bind them...

                           http://mark.mielke.cc/

_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to