Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

hansel (5700)

hansel
  (email not shown publicly)
Jabber: jamesstansell@myjabber.net

Journal of hansel (5700)

Sunday February 12, 2006
05:20 PM

run a program and capture stdout and completion status?

[ #28656 ]

I'm looking for a snippet or simple module that run an external command and capture the completion status and stdout. I found some partial snippets in the camel book, but I'd really prefer something a bit more tested/complete. This is my note to dive into CPAN. Any suggestions are appreciated.

-james.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • According to perlop [perl.org], you can simply use backticks AKA qx to run the external command and capture STDOUT; the status will be returned in $?.

    A string enclosed by backticks (grave accents) first undergoes double-quote interpolation. It is then interpreted as an external command, and the output of that command is the value of the backtick string, like in a shell. In scalar context, a single string consisting of all output is returned. In list context, a list of values is returned, one per line of output. (You