in reply to EXEC fails, sometimes

Do you check for errors?

exec(...) or die("Unable to spawn ... application: $!\n");

The above would tell you the reason the program couldn't be launched.

Replies are listed 'Best First'.
Re^2: EXEC fails, sometimes
by simpsope (Initiate) on Dec 15, 2005 at 16:29 UTC
    Yes, I get this error text: Invalid Arguement
      Ah, the exec is NOT failing. It's the Perl script that's failing. It doesn't like the arguments you passed to it. You probably used exec("program $arg1 $arg2") without quoting and escaping the contents of arg1 and arg2. (Injection attack vulnerability!) You could properly quote and escape their contents properly, or use exec("program", $arg1, $arg2) which calls the program directly instead of passing the command string to an intermidary shell.
        Well, I'd buy that arguement if the code had any arguements. I've narrowed it down by running this:
        #!c:\Perl\bin\Perl print "\n Line from print_1.pl \n"; exec "print_2.pl"; print "\n ERROR from print_1.pl: $! \n"; __END__
        And I get this result:
        j:> print_1.pl j:> Line from print_1.pl j:> ERROR from print_1.pl: Invalid arguement
        I probably didn't explain well enough that ther same code works just fine on another Windows server. Obviously a setting somewhere that different. But that's where I'm stumped.