Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
But this code doesn't give me the return code. To get only the return code I would use the following code:my $command = "host -v www.perlmonks.org 2>&1 |"; my $buff; if ( open( CMD, $command ) ) { while (<CMD>) { $buff .= "$_"; } close(CMD); } # do some parsing with $buff etc. # print $buff print "Output:\n$buff";
Now what I need is a combined version to get the return code and the output of the system command. Thanks for any advicemy $RC = system("host","-v","www.perlmonks.org"); $RC = $RC/256; print "RC:\n$RC";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re: Return code and output of system command?
by merlyn (Sage) on Apr 01, 2003 at 23:05 UTC | |
by Anonymous Monk on Apr 02, 2003 at 14:14 UTC | |
|
Re: Return code and output of system command?
by grantm (Parson) on Apr 01, 2003 at 21:50 UTC | |
|
Re: Return code and output of system command?
by Pardus (Pilgrim) on Apr 02, 2003 at 00:05 UTC |