Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Capture return value from a cmd when it errors

by mr_mischief (Monsignor)
on Aug 05, 2014 at 14:13 UTC ( [id://1096292]=note: print w/replies, xml ) Need Help??


in reply to Capture return value from a cmd when it errors

If you're using bash or a shell sufficiently similar to bash then you can redirect STDERR to STDOUT.

my @array = `cmd to be executed 2>&1`;

The advice Athanasius gave about Capture::Tiny is good advice, though. It should be much more portable to do it that way.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-04-16 08:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found