Unix Script Utility

Overview:

The unix "script" utility is a simple and effective way to capture output from your programs for submission as part of your programming assignments. It is essentially a "tape recorder" that you can turn on and which then --- until you turn it off again --- records everything that happens in your console window to a file. You can then print this file to turn in.

Details:

Turning on the script utility is easy: You just type "script <filename>" where <filename> is the name you want to give the output file where everything will be saved. After you type this, script will give you a short message to let you know it's recording. You then proceed to compile and run your program as usual.

When your program is done running, you "turn off" script by simply typing "exit".

Now, when you do an "ls", you should see a new file called <filename> in your directory. If you do "more <filename>" to view it, it should convince you that you've captured your program output.

In sum, the process usually works like this:

  1. Write, debug, and test your program. When you're sure it's working perfectly then...
  2. Type "script <output_filename>" to start the script facility.
  3. Compile your program again. This demonstrates, for the record, that your program compiles without errors.
  4. Run your program. Hopefully, this produces the desired output, demonstrating that your program works.
  5. Turn off the script facility by typing "exit".
  6. Print the recorded output to hardcopy, e.g., by doing "a2ps -1 <output_filename>".

See me if you have questions....