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:
- 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.
- Execute the command sequence that you want to capture (typically this means "run your
program").
java Hello
- Turn off the script
exit
- Now you should see a message: Script command is complete. File is
typescript.
- 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
- That's all!.
To create a script with a DIFFERENT name instead of typescript
- 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.
- Execute the command sequence that you want to capture (typically this means "run your
program").
./a.out
OR java Hello
- Turn off the script
exit
- Now you should see a message: Script command is complete. File is
output.txt.
- 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
- That's all!.
Here is an example of a script file creation:
(/lbaker/www/HTML/cosc1123) $ script output.txt
Script command is started. The file is output.txt.
(/lbaker/www/HTML/cosc1123) $ java Hello
Enter your name: Dr. Baker
Enter the grade you expect to earn in this course: A
Welcome to Computing Concepts I Dr. Baker, enjoy the course!
We hope you earn the grade of A.
(/lbaker/www/HTML/cosc1123) $ exit
Script command is complete. The file is output.txt.
Now lets look at the contents of the file, output.txt
(/lbaker/www/HTML/cosc1123) $ more output.txt
Script command is started on Thu Aug 29 15:49:58 CDT 2002.
(/lbaker/www/HTML/cosc1123) $ ./a.out
Enter your name: Dr. Baker
Enter the grade you expect to earn in this course: A
Welcome to Computing Concepts I Dr. Baker, enjoy the course!
We hope you earn the grade of A.
(/lbaker/www/HTML/cosc1123) $ exit
Script command is complete on Mon Aug 27 15:50:13 CDT 2007.