> -----Original Message----- > From: John W. Krahn [mailto:[EMAIL PROTECTED] > Sent: Thursday, 26 February 2004 1:00 PM > To: [EMAIL PROTECTED] > Subject: Re: get external process's output *and* return value > > David Le Blanc wrote: > > > > > From: John W. Krahn [mailto:[EMAIL PROTECTED] > > > > > > Andrew Gaffney wrote: > > > > > > > > Is there a way to get an external process's output *and* > > > return value? I have a program > > > > that opens a pipe to 'make', process all the input, and > > > then checks the return value when > > > > the loop ends (pipe is broken/closed): > > > > > > > > open MAKE, "make |" or die "Can't open MAKE pipe"; > > > > > > > > while(<MAKE>) { > > > > # Process input > > > > } > > > > if($make_return_value) { > > > > # An error occured with 'make' > > > > } > > > > > > > > How do I get that return value? > > > > > > perldoc -f open > > > [snip] > > > Closing any piped filehandle causes the parent > > > process to wait for the child to finish, and > > > returns the status value in `$?'. > > > > if( open(MAKE, "make |" ) ) { > > while (<MAKE>) { > > $rant; > > } > > $rc = close( MAKE );
$make_return_code = $rc; > > } else { > > print "Can't make..".$/; > > $rc = -1; > > } > > > > print "Completed with rc=$rc".$/; print "Make returned $make_return_code".$/ if defined $make_return_code; see also: perldoc perlipc man perlipc or search for 'perldoc perlipc' on google. > And how does that get make's return value? > > > [snip] > > > Closing any piped filehandle causes the parent > > > process to wait for the child to finish, and > > > returns the status value in `$?'.> > John > > > [snip] > > > Closing any piped filehandle causes the parent > > > process to wait for the child to finish, and > > > returns the status value in `$?'. > > > [snip] > > > Closing any piped filehandle causes the parent > > > process to wait for the child to finish, and > > > returns the status value in `$?'. > > > [snip] > > > Closing any piped filehandle causes the parent > > > process to wait for the child to finish, and > > > returns the status value in `$?'. > > > > How do I get that return value? > > > > > > perldoc -f open > > > > How do I get that return value? > > > > > > perldoc -f open perldoc -f open perldoc -f close > -- > use Perl; > program > fulfillment > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > <http://learn.perl.org/> <http://learn.perl.org/first-response> > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>