Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: Get Return Value from Unix

by Noame (Beadle)
on May 01, 2008 at 12:38 UTC ( [id://683909]=note: print w/replies, xml ) Need Help??


in reply to Re: Get Return Value from Unix
in thread Get Return Value from Unix

Thanks for your quick respond. I'm using the following package: use File::Tee qw(tee); "TraceLog" is an internal function that add time to the log. Your recommendation to use "system" command isn't good to me because it's print the error to log file and not return -1 if the build is failed… Or I'm wrong?

Replies are listed 'Best First'.
Re^3: Get Return Value from Unix
by mscharrer (Hermit) on May 01, 2008 at 13:01 UTC
    perldoc -f system says:
    The return value is the exit status of the program as returned by the "wait" call. To get the actual exit value, shift right by eight.

    ...

    Return value of -1 indicates a failure to start the program or an error of the wait(2) system call (inspect $! for the reason).

    So if nmake returns a failure it should return a positive integer, not -1, which would only returned if nmake wasn't found or similar.

    I would code this like that: (untested)

    my $pid = open (NMAKE, '-|', "nmake .... 2>&1"); if (!defined $pid) { warn "Couldn't start nmake"; } while (<NMAKE>) { print STDERR $_; print STDOUT $_; } close (NMAKE); my $status = $?; if ($status) { # ... }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2024-04-19 16:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found