Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: "System" will not run an executable

by serf (Chaplain)
on Dec 04, 2005 at 03:30 UTC ( [id://513898]=note: print w/replies, xml ) Need Help??


in reply to "System" will not run an executable

Firstly find the program that you're running and provide the full path to it.

If you're in +n.x you can find this with:

which nzbget

let's say it tells you it's in /usr/local/bin/nzbget you would modify your code to be:

my @args = ("/usr/local/bin/nzbget", $item); system(@args) == 0 or die "Could not run '@args' ($?): $!\n";
The $! is *very* useful to help you here because it will tell you the system error that is being thrown to tell you why the command is failing.

The ($?) will show you the return code that the program failed with (in case there was nothing useful in $!).

Watch out for the fact that system is a little different from other functions that you expect to return 1 on success such as open:

my $args = "/usr/local/bin/nzbget $item" open("$args |") || die "Can't run '$args': $!\n";
If you read system you will see that this is based around the fact that a program exiting successfully normally returns 0 (and system() does special magic on the return code to give you more useful info wrapped up in one number)

Replies are listed 'Best First'.
Re: "System" will not run an executable
by jonadab (Parson) on Dec 04, 2005 at 22:02 UTC
    If you're in +n.x

    I don't think he is. Did you read his post closely? He doesn't actually say it, but it's pretty obvious he's on Windows. First, he changes the case on the name of his executable from one usage to the next, betraying an assumption that the filesystem is not case-sensitive, which pretty much precludes any POSIX system. His title also has System in title case, further evidence he's not thinking like a *nix user.

    Second, the wording where he says that the file is executable strongly reminds me of the way DOS and Windows users state such things ("is an executable file"), not the way *nix people usually say it ("file is executable by the user" or "file has execute permission" or such). This is perhaps subtle, but the wording makes me think, "the filename has .exe on the end of it", not "chmod +x".

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (9)
As of 2024-03-28 10:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found