CS 112 Projects: Script Files
Unix-family systems have a program named script that can be used to capture
the output of text-based programs.
To use this program, just launch a terminal window and enter:
and the program will begin running.
The program will create a new file named typescript in which it will
record anything that subsequently appears in that terminal window.
We will use the script program in this course to demonstrate that your programs
work correctly by having you do the following steps inside the script recording:
list the source files (.h, .cpp) of your project,
plus any text files (.txt) on which they depend,
show that they compile and link correctly, and
run your project from the command-line.
0. Getting started
Open a Terminal window
Use the cd command to navigate to your project folder.
Enter the script command, and you should see the following message:
Script started, file is typescript
1. Listing your source files
Use the ls command to list the contents of your project directory.
Use the cat command to list your main program
and each of the .h, .cpp,
and .txt files in your project folder.
For example, for CS 112 project 1, you could enter:
cat main.cpp Song.h Song.cpp SongTester.h SongTester.cpp PlayList.h PlayList.cpp PlayListTester.h PlayListTester.cpp *.txt
Naming each source file explicitly lets you display them in an order that
makes it easiest for our grader to check and follow your program's logic.
(In general, you want to do things that make the grader's job as easy as possible,
rather than doing things that might annoy / put him or her in a bad mood.)
2. Show that they compile and link correctly
Use the cd Debug command to descend into your Debug directory.
Use the ls command to list the contents of your Debug directory.
Use the make all command to show that your program has compiled and linked
correctly. If it has, a message like this should be displayed:
make: Nothing to be done for `all'.
3. Run your program
Use the cd .. command to navigate back "up" to your project folder.
Since your executable program is in your project's Debug directory,
Run your program by entering ./Debug/ followed by its name.
For example, if your program is named proj01, you would enter:
If necessary, do this multiple times to demonstrate all the features of your program.
4. Quit the script program
After you have demonstrated that your program runs correctly
(including its various features), press Control-d
(hold down the Ctrl key, then press the d key)
to terminate the script program.
You should see a message:
Script done, file is typescript
5. Print hard copies
To print a hard copy of the typescript file
created by the script program,
use the a2ps command:
Once you have printed a hard copy of your file,
retrieve your hard copy from the printer,
staple a copy of the project gradesheet to its front,
and write your name in the appropriate place on the gradesheet.
The a2ps (ascii-to-postscript) command can be used
to print and conserve paper. Entering:
will print your typescript file "2-Up"
(2 pages per sheet of paper), which uses about
50% less paper then normal printing.
Since the paper you use comes out of your print quota,
you want to minimize the amount of paper you use.
More generally, the command:
can be used to print each of the files in
list-of-files in "2-Up" format.
If you really want to make the grader's life easier,
use a highlighter to highlight the beginning of each source file
and each of the commands you entered,
so that the grader can find them more easily.
This page maintained by Joel Adams.