Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
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 lurking in the Monastery: (7)
As of 2014-07-26 01:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (175 votes), past polls