CISC103, Fall 2006

lab09b: command line JavaScript
(first draft)

 


This is a continuation from lab09a...


 

Step 4: Making a record of your work: the Unix script command

Step 4a: Reading about the script command

Read this first to understand what you are about to do.

The web server that we use in this course, copland.udel.edu, runs the Unix operating system (instead of Windows or Mac OS).

Under the Unix operating system, you often interact by typing commands into a "terminal window", as you having been doing all along in this lab so far.

When you want to create a record of what you've done, you can use the script command. This command is similar to "turning on the VCR", or "turning on the tape recorder" to make a record of what you are doing. From the time you type script filename.txt until you type exit, everything you type goes into the file called filename.txt. Typically, you choose a name like lab09.txt or lab10.txt, and this is what you turn in to your professor or instructor.

If you go on in further Computer Science classes (e.g. CISC181, CISC220), this will become a familiar ritual—you'll do it on almost every assignment. We'll do it in several of the assignments in this course also, though not every week. So you may need to refer back to this lab in future weeks to review how it is done.

Step 4b: Making sure you are at the Unix prompt

First, to use the script command, you need to be at the Unix prompt, not the JavaScript prompt. So your next step, is to be sure you are at the Unix prompt.

To get a Unix prompt, you need to be logged in with the SSH Secure Shell Terminal program (see step 1). Then you need to make sure you have the correct prompt. To review, the Unix prompt looks like this:

copland.udel.edu%

By contrast, the JavaScript prompt looks like this:

js>

If you are at the JavaScript prompt, you need to type quit() (with the paretheses) to get back to the Unix prompt:

js> quit()
copland.udel.edu%

If you type quit without the (), you'll get something like this:

 

Step 4c: Practicing with the script command

Choose a filename

Before starting up the script program so that it is recording your work, you first need to choose a filename. Let's suppose your file will be called practice1.txt (if you decide to repeat this step, use filenames like practice2.txt, practice3.txt etc.)

Then start up the script program with that filename:

At the Unix prompt, type script practice1.txt, as shown:

copland.udel.edu% script practice1.txt
Script started, file is practice1.txt
%

Note that in this example, the prompt has now changed to just a plain percent sign, % instead of copland.udel.edu%—this is an indication that you are now "recording". Think of it like that little flashing red light inside the camcorder, or the symbol REC that shows up on your TV when you turn on the VCR.

Until you type exit at the Unix prompt, every thing you type, and everything the computer types back, will go into the file practice1.txt. So try, the following commands. What you type is shown in bold. First here's an overview—read through this, then look at the sample output, and finally try it yourself

  1. show today's date with the Unix date command
  2. show your username with the whoami command
  3. show a alendar of the current month. with the cal command
  4. go into the JavaScript interpreter with the command /www/htdocs/CIS/103/pconrad/bin/js
  5. compute what 3 + 5 is, by typing 3 + 5 at the js> prompt
  6. exit the JavaScript interpreter by typing quit()
  7. exit the script program by typing exit


copland.udel.edu% script practice1.txt
Script started, file is practice1.txt
%date
Thu Oct 26 13:46:59 EDT 2006
%whoami
pconrad
%cal
October 2006
S M Tu W Th F
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31

%/www/htdocs/CIS/103/pconrad/bin/js
js> 3 + 5
8
js> quit()
%exit
exit
Script done, file is practice1.txt
copland.udel.edu%

When you are done, transfer your practice1.txt file back to view it

Once you are finished, you should be able to use the SSH File Transfer program (click on the icon) to see that there is now a file called practice1.txt in your home directory. You can transfer that to a directory on your PC and open it with notepad. You'll see that it contains a transcript of everything you did. (See the example below)

Don't worry if there are some funny looking characters.

The picture below shows that a few characters may be funny looking. This is because of slight differences in how Windows and Unix store information. As long as you can read the file for the most part—i.e. as long as your TA and your instructor can see that you carried out the assignment successfully—small glitches in the characters or formatting are usually not an issue. But if you are not sure, check with your TA.

A few important notes

Read these over—they will help you understand why are doing these things, and how this week's lab relates to next week's lab.

Step 4d: More practice with the script command

If you understood what you did in step 4c, and everything turned out fine, you can move immediately to step 5.

If not, what you should do is ask your TA and/or instructor for help in understanding what you are doing here—and repeat step 4c again with a file called practice2.txt. Repeat this as many times as you need (practice3.txt, practice4.txt, etc.) until you are comfortable with this process. This is crucial, becuase unless you are comfortable with this, you won't be able to do the next step—which is the one you have to turn in for credit.

Step 5: The part you'll turn in for credit from lab09

@@@ Still to come!!!


Evaluation and Grading (100 pts total)

@@@ To be written @@@

Due Date: To be announced


Your next steps

@@@ To be announced @@@


Copyright 2006, Phillip T. Conrad, CIS Dept., University of Delaware. Permission to copy for non-commercial, non-profit, educational purposes granted, provided appropriate credit is given; all other rights reserved.