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

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.

Replies are listed 'Best First'.
Re^4: EXEC fails, sometimes
by simpsope (Initiate) on Dec 15, 2005 at 20:31 UTC
    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.
        Success! Fully qualifying the Perl directory fixed the problem. This worked OK:
        exec 'c:\perl\bin\perl print_2.pl';
        The path string is different, and in fact incorrect, on the machine where it fails. The real solution is to fix the path string so the code is not machine-dependent. Thanks!