Keeping a Record of Your Session with script


Keeping a Record of Your Session with script

Occasionally, you may need to keep a record of a Unix sessionfor example, if you're using Unix as part of a class assignment or need a session record to submit to your untrusting boss. You can do this using script, which keeps a record of every command you type from the shell prompt (Code Listing 15.7). You might think of typing script as pressing a Record button on a tape recorder.

Code Listing 15.7. Using script is a great way to keep records.

[ejr@hobbes ch15]$ more covermybutt Script started on Fri Aug 28 14:30:16 2005 [ejr@hobbes ch15]$ pwd /home/ejr/ch15 [ejr@hobbes ch15]$ who root     tty1       Aug 28 14:18 ejr      ttyp0      Aug 28 14:20  (calvin.raycomm.com) ejr      ttyp1      Aug 28 14:28  (calvin.raycomm.com) [ejr@hobbes ch15]$ ps ax    PID TTY STAT TIME COMMAND      1  ?  S    0:02 init [3]      2  ?  SW   0:00 (kflushd)      3  ?  SW   0:00 (kswapd)     48  ?  S    0:00 /sbin/kerneld    229  ?  S    0:00 syslogd    238  ?  S    0:00 klogd    260  ?  S    0:00 crond    272  ?  S    0:00 inetd    283  ?  S    0:00 lpd    298  ?  S    0:00 sendmail: accepting connections on port 25    310  ?  S    0:00 gpm -t ms    321  ?  S    0:00 httpd    355  ?  S    0:00 nmbd -D    368   1 S    0:00 /bin/loginroot    369   2 S    0:00 /sbin/mingetty tty2    370   3 S    0:00 /sbin/mingetty tty3    371   4 S    0:00 /sbin/mingetty tty4    372   5 S    0:00 /sbin/mingetty tty5    373   6 S    0:00 /sbin/mingetty tty6    375  ?  S    0:00 update (bdflush)    381   1 S    0:00 -bash    402  ?  S    0:00 in.telnetd    436  ?  S    0:00 in.telnetd    249  ?  S    0:00 /usr/sbin/atd    327  ?  S    0:00 httpd    328  ?  S    0:00 httpd    329  ?  S    0:00 httpd    330  ?  S    0:00 httpd    331  ?  S    0:00 httpd    332  ?  S    0:00 httpd    333  ?  S    0:00 httpd    334  ?  S    0:00 httpd    335  ?  S    0:00 httpd    403  p0 S    0:00 /bin/login -h calvin  raycomm.com -p    404  p0 S    0:00 -bash    437  p1 S    0:00 /bin/login -h calvin  raycomm.com -p    438  p1 S    0:00 -bash    449  p1 S    0:00 ispell gudspeler    450  p0 S    0:00 script covermybutt    451  p0 S    0:00 script covermybutt    452  p3 S    0:00 bash -i    455  p3 R    0:00 ps ax [ejr@hobbes ch15]$ exit Script done on Fri Aug 28 14:30:44 2005 [ejr@hobbes ch15]$ 

To Record Your Session with script:

1.

script covermybutt

At the shell prompt, type script to start recording your actions. You can save the transcript to a specified filename, as in script covermybutt. If you don't specify a file, Unix will save the transcript in the current directory as typescript.

2.

Do your thing. See you in a couple of hours.

3.



When you're done, press to stop recording the session.

4.

more covermybutt

Use more or the editor of your choice to view the script. Code Listing 15.7 shows a sample transcript.

Tips

  • Screenbased programs, such as vi, pico, pine, mutt, or links, tend to wreak havoc with the output of script. You can still read the content, but the formatting is often badly out of whack, as shown in Figure 15.3.

    Figure 15.3. Some programs give you oddly formatted script output and strange beeps when you view the script.

  • You would use script if you want to record both what you did and what happened ("geez, I typed rm unbackedupdata, then ls, and sure enough, the ls listing showed that I was in big trouble"). On the other hand, if you just want the list of commands you typed with no indication of what happened, check out history from Chapter 3 ("geez, I typed rm unbackedupdata, then I typed ls, then I logged out and cried").





Unix(c) Visual Quickstart Guide
UNIX, Third Edition
ISBN: 0321442458
EAN: 2147483647
Year: 2006
Pages: 251

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net