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

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.

Replies are listed 'Best First'.
Re^5: EXEC fails, sometimes
by ikegami (Patriarch) on Dec 15, 2005 at 21:25 UTC
    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!
        Again,
        exec 'c:\perl\bin\perl print_2.pl';
        is more security prone and slower than
        exec 'c:\perl\bin\perl', 'print_2.pl';
        since a shell is involved in the top snippet.

        Also, if you're going to put the whole path, you might as well add ".exe" to speed things up slightly.