Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: capturing exit status of a process

by hmerrill (Friar)
on Aug 06, 2004 at 11:11 UTC ( [id://380496] : note . print w/replies, xml ) Need Help??


in reply to capturing exit status of a process

The Perl Cookbook p.559 has recipe 16.4 "Reading or Writing to Another Program" where it describes using the pipe at the beginning to write to the program.
$pid = open(WRITEME, "| program arguments") or die "Couldn't fork: +$!\n"; print WRITEME "data\n"; close(WRITEME) or die "Couldn't close: $!\n";
The only difference I can see is that the Perl Cookbooks example *includes* error handling ("open(...) or die ...")on the open and close - I think that's what you are looking for to tell you if it succeeded or failed.

HTH.

Replies are listed 'Best First'.
Re^2: capturing exit status of a process
by blackrose (Initiate) on Aug 09, 2004 at 14:43 UTC
    grateful thanks for the response. What this seems to do, is verify that executing the process 'nmblookup' was indeed successful and not the fact that the result of the nmblookup was a failure. I've tried many permutations of where to capture the exit status but the only time i get anything other than 0, is if i try something that Perl doesn't like and the code itself fails.