Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

"Invalid argument" error with exec()

by Sprad (Hermit)
on Dec 12, 2003 at 18:22 UTC ( #314372=perlquestion: print w/replies, xml ) Need Help??

Sprad has asked for the wisdom of the Perl Monks concerning the following question:

I'm probably doing something stupid here, but I can't seem to figure it out. I have this line in a script:
exec "foo.pl" or die "exec failed: $!\n";
It returns the error: exec failed: Invalid argument

I've tried using single quotes, double quotes, putting the "foo.pl" in a scalar and passing that instead, using parens or not, using other commands instead of foo.pl (such as 'dir')... Nothing seems to work.

Please make me kick myself.

Pre-submission update: I was double-checking some things before hitting 'create', and I found that running the line with warnings on will give a little more information: Can't exec "cmd.exe": Invalid argument at ... So maybe it's not my fault?

---
A fair fight is a sign of poor planning.

Replies are listed 'Best First'.
Re: "Invalid argument" error with exec()
by talexb (Chancellor) on Dec 12, 2003 at 19:56 UTC

    So in English what that means is that Perl tried to shell out (as your script requested) but failed. This might have been a problem when your Perl was built, tested and installed .. or if you got your Perl from ActiveState, maybe your cmd.exe is in a non-standard location .. or maybe it's not on the current PATH.

    --t. alex
    Life is short: get busy!
Re: "Invalid argument" error with exec()
by tcf22 (Priest) on Dec 12, 2003 at 18:39 UTC
    On "perl, v5.8.1 built for MSWin32-x86-multi-thread"
    this worked fine:
    exec("exectest.pl") or die "Error $!\n";

    Update: Same code also worked on "perl, v5.8.0 built for i386-linux-thread-multi"

    - Tom

Re: "Invalid argument" error with exec()
by PodMaster (Abbot) on Dec 12, 2003 at 20:56 UTC
    on my machine you cannot type foo.pl on the commandline and expect it to run. try exec $^X, qw[ -x -S foo.pl].

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://314372]
Approved by coreolyn
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2023-02-06 16:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (34 votes). Check out past polls.

    Notices?