in reply to Piping STDOUT

don't use system, use backticks

$output = `sc \\\\$(hostname) stop SNMP`

$output will contain the results from STDOUT, for both success and failure.

Replies are listed 'Best First'.
Re: Re: Piping STDOUT
by fglock (Vicar) on Oct 02, 2002 at 13:48 UTC

    Also, this will capture both STDOUT and STDERR:

    $output = `sc \\\\$(hostname) stop SNMP 2>&1`

    note: works in Linux/Unix systems

      The above works, good thing I re-checked before posting, here is a node that has quite a few links on this subject:
      Catching STDERR with open (
      Just in case you need more ways to do it.