Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Capturing STDERR using IO::Handle

by ikegami (Patriarch)
on Nov 26, 2007 at 09:28 UTC ( [id://652949]=note: print w/replies, xml ) Need Help??


in reply to Capturing STDERR using IO::Handle

IPC::Open3's open3 is one way.

use IPC::Open3 qw( open3 ); use Symbol qw( gensym ); my $pid = open3( my $to_chld = gensym(), my $fr_chld = gensym(), my $fr_chld_err = gensym(), 'command', 'with', 'args' ); close($to_chld); close($fr_chld); my @logmessages = <$fr_chld_err>; waitpid($pid, 0);

Untested.

Replies are listed 'Best First'.
Re^2: Capturing STDERR using IO::Handle
by xdg (Monsignor) on Nov 26, 2007 at 21:31 UTC

    IO::CaptureOutput is another way.

    use IO::CaptureOutput qw/capture_exec/; my ($stdout, $stderr) = capture_exec( 'command', 'with', 'args' );

    -xdg

    Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-03-29 11:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found