Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
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


Comment on Re: executing commands and getting output
Select or Download Code

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: (6)
As of 2015-07-04 13:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls