Capture output from interactive script

I have written a menu driven script to walk users through bringing up and down an application process.
Sometimes the user tells me the script does not work taking the application down, but he can't recall seeing an error message.

Is there a way to capture std out and stderr out from an interactive script as well as have it still interacting with the user? I can set -x to trace a script, but the output shows up to the user too..

Try the script command. It will record everything...all i/o to or from the terminal.

I don't want the trace commands showing up for the user, I need them captured to a file so I can look at them.
No way to do this?

I'm not sure exactly what it is that you want here.

But trace output goes to stderr. You can capture stderr to a file like this...

exec 2>errorlog
set -x

That will send all stderr to the file. If you have some stderr stuff that you want the user to see, you will need to handle stderr for each command that might send something to stderr:

command 2>/dev/tty

Ok. this is doing what I want to a point. I am getting my trace commands to the errrorlog and not to the user executing the script.

Inside this menu script, one of the options is to show the current status of the system.
When I issue the command, it only goes to the errorlog, but not to the user. (I'm sure this is simple, please bear with me)....
I tried
command >/dev/tty and
command 2>/dev/tty

but its still putting the response into the errorlog only.

I don't really understand that, I would have expected one of those to work. But here is a sledge hammer approach...

( set +x ; exec >&- 2>&- >/dev/tty 2>&1 ; command )

This fires up a subshell, closes that trace file, resets sdtout and stderr to be /dev/tty and only then invokes the command.

I found another way around that one issue, but this is working for me. ! thanks!