Help in Creating a Script File on a Unix System

A "script" is typically a "screen capture" of commands being executed in the Unix operating environment. Creating a script file generally means that you are trying to capture in a text file, the interaction between the operating system (Unix) and the user. Most often this text file or "script" is then printed and turned in with a program assignment so that the instructor can see that the program executed correctly.

To create a basic script file, do the following:

  1. Turn the script ON (The default name of the file the script will record in is always named typescript unless you name it something else as shown later) at the command line
    script
    You will see a message back stating: Script command is started. File is typescript.

  2. Execute the command sequence that you want to capture (typically this means "run your program").
    java Birthday

  3. Turn off the script
    exit

  4. Now you should see a message: Script command is complete. File is typescript.

  5. Now you may print the file containing your script, typescript, using the a2ps command, or you may want to look at it on the screen using the more command.
    a2ps    typescript    to print the script file
    more    typescript    to view the contents of the script file on the screen

  6. That's all!.

To create a script with a DIFFERENT name instead of typescript

  1. Turn the script ON (and give a name to the file the script will record in )
    script output.txt
    You will see a message back stating: Script command is started. File is output.txt.

  2. Execute the command sequence that you want to capture (typically this means "run your program").
    ./a.out     OR     java Birthday

  3. Turn off the script
    exit

  4. Now you should see a message: Script command is complete. File is output.txt.

  5. Now you may print the file containing your script, output.txt, using a2ps, or you may want to look at it on the screen using the more command.
    a2ps    output.txt    to print the script file
    more    output.txt    to view the contents of the script file on the screen

  6. That's all!.
Here is an example of a script file creation:
/seu/cs/home/user/l/lbaker/www/HTML/cosc1123 #  script output.txt 
Script started, file is output.txt
/seu/cs/home/user/l/lbaker/www/HTML/cosc1123 # java Birthday 
Happy Birthday to you,
Happy Birthday to you,
Happy Birthday dear Dr. Camden
Happy Birthday to you!
/seu/cs/home/user/l/lbaker/www/HTML/cosc1123 # exit
Script done, file is output.txt
/seu/cs/home/user/l/lbaker/www/HTML/cosc1123 # more output.txt
Script started on Tue 26 Aug 2008 01:43:55 PM CDT
/seu/cs/home/user/l/lbaker/www/HTML/cosc1123 # java Birthday
Happy Birthday to you,
Happy Birthday to you,
Happy Birthday dear Dr. Camden
Happy Birthday to you!
/seu/cs/home/user/l/lbaker/www/HTML/cosc1123 # exit

Script done on Tue 26 Aug 2008 01:44:02 PM CDT
/seu/cs/home/user/l/lbaker/www/HTML/cosc1123 #