in reply to Executing an application in Perl/CGI

Your call to system needs to have parentheses for the die to work (aside from the fact that system returns "false" on success).

system 'cmd.exe /c notepad.exe' || die 'no notepad'; # is the same as system( 'cmd.exe /c notepad.exe' || die 'no notepad' ); # but you want system( 'cmd.exe /c notepad.exe' ) && die 'no notepad'; # or you could do system 'cmd.exe /c notepad.exe' and die 'no notepad';

You could also get a little more explicit about what you expect from system:

0 == system 'cmd.exe /c notepad.exe' or die 'no notepad';

Replies are listed 'Best First'.
Re^2: Executing an application in Perl/CGI
by Anonymous Monk on May 22, 2007 at 19:33 UTC
    This works for the error, it doesn't launch. However why does this not work on a server end put works alright locally executed. Is this an issue with the path? Thanks for the suggestions.
      This works for the error, it doesn't launch. However why does this not work on a server end put works alright locally executed. Is this an issue with the path?

      It may be. However, to quote from perldoc -f system:

      You can check all the failure possibilities by inspecting $? like this: if ($? == -1) { print "failed to execute: $!\n"; } elsif ($? & 127) { printf "child died with signal %d, %s coredump\n", ($? & 127), ($? & 128) ? 'with' : 'without'; } else { printf "child exited with value %d\n", $? >> 8; }
        Exited with value 225