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

Re: Inconsistent system call from backticks vs system()

by cbro (Pilgrim)
on Jul 01, 2003 at 14:09 UTC ( #270476=note: print w/replies, xml ) Need Help??

in reply to Inconsistent system call from backticks vs system()

You may want to read this. That way I don't have to get too detailed. But in general:
When you run a command with backticks you should not need to redirect using the 2>&1. All output from the program will be redirected to your variable(AFAIK); when you want to capture output, use the backticks...not system(). Try removing the 2>&1 and see if you get the behavior you expected when using backticks.

Replies are listed 'Best First'.
Re: Re: Inconsistent system call from backticks vs system()
by Tanalis (Curate) on Jul 01, 2003 at 14:15 UTC
    The reason for the 2>&1 is to trap STDERR as well as STDOUT, as perlop explains in its examples.

    I'm aware that system() doesn't trap output, and I don't intend using it, but unless I can get the backticks to work as I expect them to (system with STDOUT and STDERR trapping) I'll have to think of some other way to do this :/

    Thanks for the feedback.

    -- Foxcub

      I know why you used 2>&1. But I'm saying that w/backticks you shouldn't need to trap. UPDATE: Deleted example Ahh, but w/further testing...I found that it was the C program printing. I did need the trap, and I was incorrect on my previous post. I apologize. (It did work fine w/the trap however. The post below mine makes a good point about the './' and a possible path issue)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://270476]
[marto]: good morning all
[Discipulus]: ah ah! welcome back marto!
[Corion]: Hi marto and Discipulus!

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (10)
As of 2018-06-20 08:42 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (116 votes). Check out past polls.