http://qs1969.pair.com?node_id=1171410


in reply to Capturing bash output without displaying STOUT in terminal

Maybe Capture::Tiny might be able to help you to capture the output of a system command without displaying the output to the terminal.

  • Comment on Re: Capturing bash output without displaying STOUT in terminal

Replies are listed 'Best First'.
Re^2: Capturing bash output without displaying STOUT in terminal
by edimusrex (Monk) on Sep 08, 2016 at 16:15 UTC
    Yea, I am looking into Capture::Tiny right now, the output of this command still doesn't seem to want to be captured, I will play around with it some

      Based on your response to my post as well as stevieb's initial post, I'd agree with stevieb that it looks like the command that you're running is sending the response to STDERR. As stevieb has pointed out, his suggestion of using backticks will only let you capture STDOUT. Capture::Tiny can capture both STDOUT and STDERR (and exit code) for system commands.

        Or, you can append 2>&1 to the command line, allowing STDERR to be captured through STDOUT. Only recommended if the normal STDOUT is empty.

      Some programs (e.g ssh when asking for a password) write directly to the terminal, not STDOUT.

      $ ssh ikegami@209.197.123.153 2>&1 >/dev/null ikegami@209.197.123.153's password:

      You have to create pseudo-tty's (as Expect does) in that case.


      IPC::Run supports capturing STDOUT and STDERR separately, and easily. It even supports pseudo-tty creation if you need them.