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:

   script
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:
  1. list the source files (.h, .cpp) of your project, plus any text files (.txt) on which they depend,
  2. show that they compile and link correctly, and
  3. run your project from the command-line.

0. Getting started

  1. Open a Terminal window
  2. Use the cd command to navigate to your project folder.
  3. Enter the script command, and you should see the following message:
          Script started, file is typescript
      

1. Listing your source files

  1. Use the ls command to list the contents of your project directory.
  2. 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

  1. Use the cd Debug command to descend into your Debug directory.
  2. Use the ls command to list the contents of your Debug directory.
  3. 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

  1. Use the cd .. command to navigate back "up" to your project folder.
  2. 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:
         ./Debug/proj01 
    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.

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.

That's it!


Calvin > CS > 112 > Projects
This page maintained by Joel Adams.