February 24th, 2011, 04:11 PM
Capture all screen i/o and error to a file
This isn't a simple redirect problem. I need to capture everything that appears on the terminal when a script runs and send it all to a file. This includes output, error, and user input.
The 'script' command is unsuitable because it forks a shell and when 'script' ends, so do any processes associated with that shell. Sometimes these processes have to continue after 'script' ends and 'script' doesn't allow that.
The reasons the usual I/O redirects (including tee) won't work are that user input isn't captured and also user prompts that request input never appear. Most of the time (but not always) I am calling a perl script, but it could be a shell script or simply a series of commands.
I have to remain in whatever shell I'm in when I log in to a system, so a shell-specific script is out - has to be straight Linux commands. I am starting to think that what I need may not be possible to do in the context of the shell, but I thought I'd ask anyway - you never know.
Thanks for reading all this!
Last edited by bluecrab22; February 24th, 2011 at 04:12 PM.
February 24th, 2011, 04:54 PM
Using screen you can log everything that happens using "Ctrl-A" "H".
The nice thing about screen is that you can detach from a running screen session and all processes will remain executing. I'm not sure how that interacts with what is being logged, but with some experimentation you can probably get what you are after.
True happiness is not getting what you want, it's wanting what you've already got.
February 25th, 2011, 09:40 AM
Thanks. I'm going to work with 'screen' for a while and see if it is appropriate for what I need.
Originally Posted by L7Sqr