Search code examples
linuxtee

Tee user responses to prompts


Is it possible to have tee emit responses to prompts?

That is, I run a program (e.g. openssl req) that prompts for user inputs, and run it through tee to produce a log. tee emits the prompts produced by the program, but not the user's responses.

openssl req *some options* | tee -a openssl-req.log

The user sees

Generating a RSA private key
snip
Country Name [US]:FA
State or Province Name [CA]:
snip*

but openssl-req.log contains

Generating a RSA private key
snip
Country Name [US]:State or Province Name [CA]:City or other
snip

The user responses, including line-breaks, are not present in tee's output.


Solution

  • D. Rankin's suggestion works. A little trickery gets the full output, including the command:

    script -q -a logfile -c "(set -x ;command)"