28 December 2009 View Comments

Records a Shell Session in Unix System


The script utility records all or part of a login session, including your input and the system’s response. It has its advantages. For example, when you cat a file that has captured a vim session, the session quickly passes before you eyes. By default script captures the session in a file named typescript which will contains all the inputs and outputs, which then let you to edit it as you wish in the future.


ss@notebook /home/ss

$ script

Script started, file is typescript

ss@notebook /home/ss

$ whoami

ss

ss@notebook /home/ss

$ ls -l /bin | head -5

total 5456

-rwxr-xr-x 1 root root 875596 2009-09-14 06:09 bash

-rwxr-xr-x 1 root root 30192 2009-06-30 01:18 bunzip2

-rwxr-xr-x 1 root root 30192 2009-06-30 01:18 bzcat

lrwxrwxrwx 1 root root 6 2009-12-03 22:48 bzcmp -> bzdiff

ss@notebook /home/ss

$ exit

exit

Script done, file is typescript

use the exit command to terminate a script session. You can then view the file you created with cat, less, more, or an edit.

ss@notebook /home/ss

$ gedit typescript

blog comments powered by Disqus