Incidentally the last place I recall seeing the internal/external command 
differences documented was in either DOS 5 or 6. You can infer this from 
the lack of a COPY.exe but it's just not mentioned explicitly anymore.

Josh




[EMAIL PROTECTED]
Sent by: [EMAIL PROTECTED]
10/31/2002 11:22 AM

 
        To:     "Joe Rioux" <[EMAIL PROTECTED]>
        cc:     [EMAIL PROTECTED], 
[EMAIL PROTECTED]
        Subject:        RE: Interpreting $?


I didn't realize you needed more information. This is a mysterious thing 
and hopefully I won't go wrong on my interpretation of win32 behaviour. 
The first issue is that COPY isn't an actual executable to be loaded and 
executed. It's an internal routine of the shell and to get that to work 
you've got to get a shell to run the command line "COPY foo bar". From 
reading the perl source it looks like if there are no shell metacharacters 

then perl attempts to call the program with the Win32 API 
CreateProcess("COPY foo bar") call. I would expect your "COPY foo bar" 
call to fail on that since there isn't a COPY.(exe|bat|com|whatever) in 
your PATH environment variable (by default). If there are shell 
metacharacters then the system() call is passed off to perl's idea of a 
good shell interpreter and CreateProcess() is ignored. The default is that 

cmd.exe is preferred over command.com for those OSes that have cmd.exe. If 

you add cmd.exe to a Win9x then perl will probably ignore it since it 
doesn't expect it. You can override this shell selection by setting the 
PERL5SHELL environment variable to something like "cmd.exe \x\c" or 
"command.exe \c" or whatever else is appropriate. From that point I might 
actually expect your COPY command to be recognized and performed since it 
would execute within the context of shell.

The issue is - how to ensure your command is handled by the shell when 
perl has disgression to avoid it if it feels like it. The answer is simple 

- force the issue and execute it directly like system("cmd /c \"COPY foo 
bar\""). That form will handle both cases where either CreateProcess() or 
the shell can handle it.

Anyhow - this should be enough information to help you solve the problem 
in whatever manner is appropriate for you.

Josh




"Joe Rioux" <[EMAIL PROTECTED]>
Sent by: [EMAIL PROTECTED]
10/31/2002 10:51 AM

 
        To:     "Mark Mielke" <[EMAIL PROTECTED]>, "$Bill Luebkert" 
<[EMAIL PROTECTED]>
        cc:     <[EMAIL PROTECTED]>
        Subject:        RE: Interpreting $?


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?

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?

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



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



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

Reply via email to