Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Pipe, STDERR, STDOUT, and friends

by xdg (Monsignor)
on Sep 22, 2008 at 12:36 UTC ( [id://713002]=note: print w/replies, xml ) Need Help??


in reply to Pipe, STDERR, STDOUT, and friends

There are lots of CPAN modules to make this easier. If it's just a command you're running and you don't need to manage its STDIN, I'd use IO::CaptureOutput, which is my favorite swiss-army tool for capturing output either from Perl or from an external command. (So much my favorite that I took over maintainership when I needed bugs fixed and the author was non-responsive.)

use IO::CaptureOutput qw( qxx ); my ($stdout, $stderr) = qxx( $somecommand, @args, $filename );

-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://713002]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (1)
As of 2024-04-25 03:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found