Tuesday, March 17, 2009

How to capture Unix console screen output?

Many of you might want to capture the screen output of the unix console for references later or wanted to show the output to another counterpart.

This command is particularly useful in 2 scenarios:

1. During a training, where instructor do a demo using the endless list of command that you have difficulty to remember and jotting down.

At many instances, even you can jot down the command you might not even able to remember what is the output of the command.

Put it this way, many of us, learn from example. Hence being able to capture the screen output is very important.

2. If you are a student and you need to show your program output to your lecturer. Use this command.

THE COMMAND IS:

script [space][filename]

CTRL+D to exit the script command

=========== For Instance =========
$ script script.out
Script started, file is script.out
$ date
Tue Mar 17 17:04:07 SGT 2009
$ time

real 0m0.00s
user 0m0.00s
sys 0m0.00s
$ ^D
Script done, file is script.out


$ cat script.out
Script started on Tue Mar 17 17:04:03 2009
$ date
Tue Mar 17 17:04:07 SGT 2009
$ time

real 0m0.00s
user 0m0.00s
sys 0m0.00s
$ ^D

script done on Tue Mar 17 17:04:11 2009
$

So simple, right ......


No comments: