Script is a utility program that captures everything printed on your terminal. It is very useful to create samples of your program running. Let us assume that you are running program number one, which you have saved as hello.cpp. You can create a script file (I'll call script.1) with the command:
script script.1
Then everything that is on the screen will be put into the file script.1, until you type:
exit
Note: Be aware that as soon as you have typed the script command, the file name given will be destroyed. If you want to append to a file, use the command:
script -a script.1
Do not run any of the editors (vi or pico) while you are creating a script file. You will have problems when you try to print the file.
A sample session is given below:
>script script.1 Script started, file is script.1 >cat hello.cpp /* * * Your name here * CS 213 * Program #1 * * This program writes "Hello, World!" *********************************************************/ #include <stdio.h> int main () { cout << "Hello, World!" << endl; } >g++ hello.c >./a.out (might be a.out) "Hello, World!" >exit Script done, file is script.1
Now, the file script.1 contains what you have seen on the screen. In this case, everything from Script started to Script done.
If you print a script file using lp -dlaser script.1, there will some strange characters in the printout, like ^H for every carriage return. In order to avoid this, use the program a2ps.