Redirect ALL terminal output to file and screen (for entire session)
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Redirect ALL terminal output to file and screen (for entire session)
Is there one command that will let me record an entire terminal session (with any possible errors) to a text file while also seeing all output on screen too?
I know it can be done for individual commands, but I'm looking to do this for an entire session where the individual commands will be normal (i.e., not piped into tee, etc.).
It would be even better if the command prompt is captured too. The obvious utility of this makes me think someone surely has come up with a solution long ago (probably in the 60's).
(I'm sure it goes without saying, but subsequent output in that session should be appended to the file. The file should contain the full history, with all output and errors, of the session.)
Last edited by Mountain; 07-06-2010 at 11:58 AM.
Reason: added parenthetical
OK, so I found out about script (man script).
Is this the only solution? It would be great to have an output file that looks more like what I see on the screen (i.e., without showing all the special non-printing characters).
Yes, I already read the man page for script as I said. I do not see anything in there about cleaning up the non-printing chars from the output. Am I missing something? Thanks
Is there one command that will let me record an entire terminal session (with any possible errors) to a text file while also seeing all output on screen too?
Take a look at the 'screen' command. Using the logging option (-L)
whatever you type and whatever is output to STDERR or STDOUT goes into the log file.
While 'screen' is intended to permit multiple terminal or console sessions connected to a single terminal, the logging feature is at least as important for me.
Take a look at the 'screen' command. Using the logging option (-L)
whatever you type and whatever is output to STDERR or STDOUT goes into the log file.
While 'screen' is intended to permit multiple terminal or console sessions connected to a single terminal, the logging feature is at least as important for me.
~~~ 0;-Dan
Thank you. It's nice to have another option in addition to script.
If I understand correctly, I simply open konsole and type "screen -L". then I do whatever work I planned to do in the terminal session. When finished, I type "exit". The log is found in screenlog.0 (or generally, screenlog.N, I presume).
The output doesn't need to be run through a cleanup script.
Another option could be to use 'rootsh'. While 'rootsh' can be started and used like 'screen' or 'script' it is a shell wrapper. So in contrast to the others it can be used as a login shell, recording input and output without requiring the user to remember to start it and without user intervention. Logs must be ran through a scrubber though, yours will work just fine.
...
The output doesn't need to be run through a cleanup script.
It is human readable without intervention. Since STDIN and STDOUT/ERR are mixed, you will need to scrub the log if you want a script for later execution.
~~~ );-Dan
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.