The Unix "SCRIPT" command : a command recorder
Atul.Singh 270002HUVT Visits (1756)
The most common use of script is to document terminal session. By running script you log all the information displayed on your terminal. You can then print the log file or view it with an editor. In a way script is a specialized tee for the shell.
To start a script session, issue the command script to the Unix shell; then continue on working normally as long as you like. If you don't provide a file name to the script command, it places its output in a default file named typescript, you can name your script file hwn.txt, where n is the number of the programming assignment you're doing.
Whatever you do, do not use the name of your program's source code file as the filename for the output of the script command. If you type script hello.c, the output from the script command will overwrite and destroy whatever used to be in hello.c
When you decide you don't need to record stuff anymore, exit from the scripting session by issuing the command exit to the Unix shell.When you run script a new shell is forked. This new shell makes a complete copy of everything displayed on your terminal. It reads standard input and output for your terminal tty and stores the data in a file. The default filename is typescript.
To exit from a script session you simply press Ctrl-D or type exit.
Format of the script command.script [ -a ] [ typescript_file ]
-a Append the output of script to file.
Normally script begins writing to a new file; if the file exists it is overwritten unless you specify the -a option.
This is the only option present in all versions of Unix.
Exp :script log1.txt
script –a log1.txt
njoy the simplicity..