Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re^6: capturing command output

by pklausner (Scribe)
on Jan 26, 2012 at 16:21 UTC ( #950157=note: print w/replies, xml ) Need Help??

in reply to Re^5: capturing command output
in thread capturing command output

Almost. Although your backticks is a bit short on the logging and redirection part ;-)

Replies are listed 'Best First'.
Re^7: capturing command output
by JavaFan (Canon) on Jan 26, 2012 at 18:00 UTC
    It's using the same logging as the OP did (that is, none). And I fail to see why backtick "$cmd 2>&1", using the same $cmd from the OP doesn't give you redirection.

      Although the original does no logging, I dared to propose that this might be useful for non-trivial calls. As might be a redirection duplication of stderr and/or stdout to some location where you can inspect it. Or show it depending on a verbosity option.
      And yes, all of this is unnecessary in perfect code.

        Sure, but that still doesn't explain why it's better to do your own implementation of backticks right from the start. Given my trivial implementation of your wished extra layer of indirection, gives you all the hooks you want to add logging, redirection, or whatever you may wish to do. But unless there's an actual reason to do the logging, redirection, or whatever, there's no need to do it.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://950157]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2017-04-25 01:42 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (447 votes). Check out past polls.