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

Re: executing commands and getting output

by bm (Hermit)
on Sep 05, 2003 at 09:10 UTC ( #289139=note: print w/ replies, xml ) Need Help??


in reply to executing commands and getting output

Use backticks. This only captures STDOUT, so you should add shell redirection to capture any errors that appear on STDERR:
my $cmd = '/this/is/a/command -sdfw'; my $result = `$cmd 2>&1`; do_something() if ($result =~ /regex/);
see  perldoc -q capture
--
bm

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2016-06-28 21:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (364 votes). Check out past polls.