Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2017-06-25 06:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (564 votes). Check out past polls.