in reply to system command erroneously states 'can't spawn <executable>'

Sometimes the error message refers to "cmd.exe" even though I am trying to run another executable.

The shell (cmd.exe) is needed to parse the command line in some instances. This is definitely the case when redirection (>, < or |) is used. There may be other cases too.

perl uses environment variable PATH to locate cmd.exe. It should use environment variable COMSPEC to which shell and where it's located, but it doesn't.

Note also that this does not occur if I execute the system command via a perl -e "system(...)"

Maybe cause you didn't turn on warnings, and you had warnings on in your script?

Historic tidbit that may be relevant: Negative return codes didn't use to be valid in DOS. The return value argument of the exit program system call was an unsigned byte. This may have changed in Windows.

Replies are listed 'Best First'.
Re^2: system command erroneously states 'can't spawn <executable>'
by jimbojones (Friar) on Feb 25, 2005 at 16:32 UTC
    Hi

    According to the source (win32.c), COMSPEC isn't called ...
    /* we don't use COMSPEC here for two reasons: * 1. the same reason perl on UNIX doesn't use SHELL--rampant and * uncontrolled unportability of the ensuing scripts. * 2. PERL5SHELL could be set to a shell that may not be fit for * interactive use (which is what most programs look in COMSPE +C * for). */
    I don't really understand the second point ...

    - jim