May 19, 2011

How to record command line output

if we want to record the output in Linux command line, we could use "script" command.

script [-a] [-f] [-q] [-t] + file name


Append the output to file or typescript retaining the prior contents.


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'.


Be quiet.


Output timing data to standard error. This data contains two fields, separated by a space. The first field indicates how much time elapsed since the previous 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.

To exit the recording, we need to use "ctrl + d".

For example, we record the command line output to a log file whose name is "MyRecord".

$ script MyRecord.log

Then it will begin to record all the information displayed by command line. Finally, "ctrl + d" will exit and it will show "Script done, file is MyRecord.log"

No comments:

Post a Comment