in reply to Re: EXEC fails, sometimes
in thread EXEC fails, sometimes

Yes, I get this error text: Invalid Arguement

Replies are listed 'Best First'.
Re^3: EXEC fails, sometimes
by ikegami (Patriarch) on Dec 15, 2005 at 16:33 UTC
    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.
        On a Windows machine? Try exec 'perl', 'print_2.pl';. Use the full path to perl if necessary.