in reply to Re: capture STDOUT without printing to screen
in thread capture STDOUT without printing to screen
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.
|
|---|