Saturday, September 22, 2007

Record your command line session

The commands you execute on the command line and their outputs are very helpful to debug problems. You might even want to record your sessions as part of an audit policy.

Linux and Unix systems make it very easy using the script command:

script [-a] [-c COMMAND] [-f] [-q] [-t] [file]

DESCRIPTION
Script makes a typescript of everything printed on your terminal. It is useful for students who need a hardcopy record of an interactive session as proof of an
assignment, as the typescript file can be printed out later with lpr(1).

If the argument file is given, script saves all dialogue in file. If no file name is given, the typescript is saved in the file typescript.

Options:

-a Append the output to file or typescript, retaining the prior contents.

-c COMMAND
Run the COMMAND rather than an interactive shell. This makes it easy for a script to capture the output of a program that behaves differently when its std-
out is not a tty.

-f Flush output after each write. This is nice for telecooperation: One person does âmkfifo foo; script -f fooâ and another can supervise real-time what is
being done using âcat fooâ.

-q Be quiet.

-t Output timeing data to standard error. This data contains two fields, separated by a space. The first field indicates how much time elapsed since the previ-
ous output. The second field indicates how many characters were output this time. This information can be used to replay typescripts with realistic typing
and output delays.

No comments:

About Me

California, United States