STDOUT and STDERR from command lines


J

Joe

I wish to have an easy way to capture STDERR and STDOUT from a command line(system("$cmd") or `$cmd`). The methods give on perl FAQ list is complicated (http://perldoc.perl.org/perlfaq8.html#How-can-I-capture-STDERR-from-an-external-command). However the "Net::SSH::perl" module has a very nice way to capture them like in:

my($stdout, $stderr, $exit) = $ssh->cmd($cmd);

I wonder is there a function/module to allow something like:

my($stdout, $stderr, $exit) = `$cmd`;

I did search but fail to find so far. Any advice would be appreciated.

joe
 
Ad

Advertisements

J

Jim Gibson

Joe said:
I wish to have an easy way to capture STDERR and STDOUT from a command line
(system("$cmd") or `$cmd`). The methods give on perl FAQ list is complicated
(http://perldoc.perl.org/perlfaq8.html#How-can-I-capture-STDERR-from-an-extern
al-command). However the "Net::SSH::perl" module has a very nice way to
capture them like in:

my($stdout, $stderr, $exit) = $ssh->cmd($cmd);

I wonder is there a function/module to allow something like:

my($stdout, $stderr, $exit) = `$cmd`;

I did search but fail to find so far. Any advice would be appreciated.

The methods given in the FAQ are complicated, but perhaps that
complexity is required. I would try one of the following and see how
far I got:

IPC::Open3
IPC::Run
IPC::Run3
 
Ad

Advertisements

J

Joe

Wow, it's great to learn. THANK YOU ALL so much!
(I would have no way to find them myself :)

joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top