Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

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

Replies are listed 'Best First'.
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`;


      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?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://545409]
Approved by ww
and the fire pops...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2017-01-18 17:36 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (161 votes). Check out past polls.