Linux/Unix – Recording a Shell Session…

Recording a Shell Session

Use script to create a typescript, or “capture log,” of a shell session−−it writes a verbatim copy of your session to a file, including commands you type and their output. The first and last line of the file show the beginning and ending time and date of the capture session. To stop recording the typescript, type exit at a shell prompt. By default, typescripts are saved to a file called `typescript’ in the current directory; specify the file name to use as an argument. To create a typescript of a shell session and save it to the file `log. 20081028, type:

$ script log.20081028

Script started, output file is log.20081028

$ hostname


$ apropos bash 62; bash.commands

$ exit


Script done, output file is log.19990817


In this example, the typescript records a shell session consisting of two commands (hostname and apropos) to a file called `log. 20081028. The typescript looks like this:

Script started on Tue May 25 14:21:52 1999

$ hostname


$ apropos bash 62; bash.commands

$ exit


Script done on Tue May 25 14:22:30 1999

NOTE: It’s possible, but usually not desirable, to run script from within another script session. This usually happens when you’ve forgotten that you are running it, and you run it again inside the current typescript, even multiple times−−as a result, you may end up with multiple sessions “nested” inside each other like a set of Russian dolls.


About msotela

This blog is for anyone who wants to access the power of a Linux system as a systems administrator or user. You may be a Linux enthusiast, a Linux professional, or possibly a computer professional who is increasingly finding the Windows systems in your data center supplanted by Linux boxes.

Posted on March 16, 2009, in Unix/Linux. Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: