Perl Monk, Perl Meditation | |
PerlMonks |
system command erroneously states 'can't spawn <executable>'by Sandy (Curate) |
on Feb 24, 2005 at 22:19 UTC ( [id://434282]=perlquestion: print w/replies, xml ) | Need Help?? |
Sandy has asked for the wisdom of the Perl Monks concerning the following question:
Also see system command can't spawn cmd.exe
On more than one occasion, I have received the dreaded dos message Can't spawn <executable> after executing a perl command
Sometimes the error message refers to "cmd.exe" even though I am trying to run another executable. Well, one time (once too many) I knew that since my perl program had been happily working for many months, and now wasn't (after i modified the executable in question), it had to do with the executable, not with perl. So, with a little experimentation, I have discovered that this system error occurs if the executable returns with a negative return code (at least on WinNT, and definately not on solaris). It only happens when called from a perl script, and not from a , and only when using the system command. For example, with the following c-code program
Note that with a return code of zero or a positive number, there is no error message, but when the return code is negative (any negative number gives same return code), the c-executable still executes, but prints that annoying error on the screen. Important note: Even though there is that annoying message that initially had me convinced something was very wrong, it turned out (at least in these cases) that my executable executed quite happily, and everything was a-ok. Note also that this does not occur if I execute the system command via a perl -e "system(...)" For those with sharp eyes, please note that there was no difference between and and UPDATE: As noted by ikegami, the warning does occur from the perl command line if I 'use warnings'. Also: If I change the system command to redirect the output, it does indeed say 'Can't spawn "cmd.exe"'. So, now that I know that a negative return code from an executable causes DOS to barf up an error/warning message, I can deal with it.
Back to
Seekers of Perl Wisdom
|
|