Friday, October 3, 2008

Shell Session Recording

In order to record the commands and their output in a shell session,
you can use script command. For example:

[mitesh@linuxbox:370:~]$ script
Script started, file is typescript
[mitesh@linuxbox:370:~]$ ls
CvsRoot Desktop Documents Download Examples linux Music PDF Pictures Programming Public Templates typescript Videos workspace
[mitesh@linuxbox:371:~]$ /bin/date
Fri Oct 3 16:51:42 IST 2008
[mitesh@linuxbox:372:~]$ whoami
mitesh
[mitesh@linuxbox:373:~]$ exit
exit

Script done, file is typescript

You can view the output file typescript file using your favorite editor.
$ cat typescript
Script started on Friday 03 October 2008 04:51:27 PM IST
[mitesh@linuxbox:370:~]$ ls
CvsRoot Desktop Documents Download Examples linux Music PDF Pictures Programming Public Templates typescript Videos workspace
[mitesh@linuxbox:371:~]$ /bin/date
Fri Oct 3 16:51:42 IST 2008
[mitesh@linuxbox:372:~]$ whoami
mitesh
[mitesh@linuxbox:373:~]$ exit
exit

Script done on Friday 03 October 2008 04:51:54 PM IST

PS: you can save the output to any file, you want instead of typescript in
current directory. For example
$ script shell_session_20081003.log
...
...
$ exit
$ cat shell_session_20081003.log

No comments: