in reply to capture STDOUT without printing to screen

Backticks (AKA qx) capture all of STDOUT. Nothing will ever make it to the screen.

My guess is that your info is actually sent to STDERR. Try redirecting that to /dev/null in the command line. (nul on PC)

  • Comment on Re: capture STDOUT without printing to screen

Replies are listed 'Best First'.
Re^2: capture STDOUT without printing to screen
by radiantmatrix (Parson) on Dec 01, 2004 at 17:27 UTC

    If you are running a *NIX, you may be able to do this:

    my @lines_of_output = `sh /path/to/binary 2>&1`;

    You may not even need the 'sh' if your default shell supports the same redirection syntax. The '2>&1' tells the shell (which will execute your binary) to redirect all output on STDERR to STDOUT. STDOUT stuff will be left alone.

    So, unless your external program is doing something odd like opening /dev/console or /dev/tty or something, the above should get you exactly what you'd otherwise see on the screen.


    radiantmatrix
    require General::Disclaimer;
    Perl is