in reply to Re^2: Get Return Value from Unix
in thread Get Return Value from Unix
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) { # ... }
|
|---|