Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Running external command from perl but cannot capture output

by Syco54645 (Initiate)
on Apr 24, 2006 at 22:07 UTC ( #545409=perlquestion: print w/ replies, xml ) Need Help??
Syco54645 has asked for the wisdom of the Perl Monks concerning the following question:

Hello, hoping that someone can help me here. What i am doing is running the command
mac "foo.ape" -v
with perl by doing
@foobar=`mac \"foo.ape\" -v`;
i know that this would usually suppress the output of the called program and store the output into the variable @foobar, but this is not the case. it does in fact store the output, but it does not suppress it. so instead of a nice clean terminal when running my script i get
--- Monkey's Audio Console Front End (v 3.99) (c) Matthew T. Ashland - +-- Verifying... Progress: 7.1% (52.8 seconds remaining, 4.0 seconds total)
what i am trying to do is not have any of that output and just print a message like foo.ape file is ok or something similar. that is not the important part as i can accomplish that easily. what is important is that i just want that output to stop so that i can replace it. any help would be greatly appreaciated -Syco54645

Comment on Running external command from perl but cannot capture output
Select or Download Code
Re: Running external command from perl but cannot capture output
by m.att (Pilgrim) on Apr 24, 2006 at 22:26 UTC
    Is it possible that it's outputting on STDERR as well as STDOUT? You can try redirecting STDERR somewhere else in the command such as:

    @foobar=`mac \"foo.ape\" -v 2>/dev/null`;

    Or, if you want to capture STDERR as well:

    @foobar=`mac \"foo.ape\" -v 2>&1`;

    m.att

      thanks for the reply. here is what i have right now
      @test=`mac \"$_\" -v >/dev/null 2>&1`;
      this suppresses the output, but does not put anything in @test. i am not too sure what to do.
        Leave out the >/dev/null part.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2014-07-31 23:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (255 votes), past polls