Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Perl 5.10.1 - compare external program output with a list of known error codes

by Marshall (Canon)
on Sep 20, 2016 at 00:17 UTC ( [id://1172191]=note: print w/replies, xml ) Need Help??


in reply to Perl 5.10.1 - compare external program output with a list of known error codes

You are capturing the output of a backtick operator. One thing is missing from this, the actual status of that command.

This might be helpful:
PerlVar and new ${^CHILD_ERROR_NATIVE} variable in Perl 5.10

${^CHILD_ERROR_NATIVE}
The native status returned by the last pipe close, backtick (`` ) command, successful call to wait() or waitpid(), or from the system() operator. On POSIX-like systems this value can be decoded with the WIFEXITED, WEXITSTATUS, WIFSIGNALED, WTERMSIG, WIFSTOPPED, WSTOPSIG and WIFCONTINUED functions provided by the POSIX module.

Under VMS this reflects the actual VMS exit status; i.e. it is the same as $? when the pragma use vmsish 'status' is in effect. This variable was added in Perl v5.10.0.

I am thinking that this would give you the summary of "it worked or it didn't work?". Maybe that is helpful? Parsing the output of the command seems to be a difficult way to do that?

If you want the last line of the backtick output, you can assign that to an array and then just look at the last line. On Windows:

my @out = `help copy`; print $out[-1]; #the last line of output

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-03-28 13:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found