Instructions based off of Greg Boyd's Assignment Guidelines

Facilitating Grading

You are responsible to do your assignments so that the grader can readily follow what you have done. If I can't readily follow your assignment, I can't grade it. Resubmission of ungraded assignments are permitted but can incure a penalty.

Using Canvas For Handing In Assignments

We will use Canvas to submit the results of the homework assignment. Make sure to indicate in a separate file or in the Canvas Textbox the following:

Never edit your final script file, but you may enter the above information into the comment area or in a separate text file

Preparing Assignments with Script

Each script session must be placed in a separate file. Make sure to name your script output files. If you use the default name of typescript, script will silently overwrite any existing typescript file which may be for another part of the assignment. Picking out a good standard naming scheme is something that a pro-scripter often has to think about. Make sure that whatever name you choose is not the name of an existing file. Remember, Unix doesn't warn you if you do this - it simply erases the file with the same name and starts a new one

Each script session must begin with a standard descriptive header. This consists of:

Example

You are doing Assignment Two. You should begin the script program and name the script file, using a command such as

$ script asmt02.script

This starts script and names the script file asmt02.script

If you use the name of an existing file here the file will be overwritten by script

Unix will respond:

Script started, file is asmt02.script

The first lines you should type after beginning the

script

program are

        $
        $ #******* Assignment Two Your-Name-Here
        $
        $ date
        [the date will appear here]
        $ pwd
        [the name of the current directory will appear here]
        $ id
        [your user name and other information will appear here]
      

Step Markers

Some parts of the assignments are fairly long. Since the script output consists of Unix commands, these can be difficult to follow. To allow you to make mistakes and me to follow the result, these assignments are divided into distinct steps. Each step is numbered, and literally contains the word Step

Step markers in a script file help label steps that you want the reader to pay attention to

If a procedure contains Steps, as does the one on the left above, you must indicate where the output of each step begins in your script session by inserting a Step marker.

Step markers are inserted directly into the script session by you typing at the keyboard. To keep the grader in a good mood while grading (which is to your benefit), observe the following when annotating with step markers:

  1. highlight them by placing a blank line before and after the marker and add some leading asterisks.
  2. be sure to indicate the number of the Step that is being started.

When you begin a new step of the assignment, which is indicated in the assignment instructions as Step 2., for example, you should insert comments such as

      $
      $ # Step 2
      $
      

prior to the commands to perform the step itself. (The # begins a comment. This indicates that the remainder of the line is an annotation. If you do not start the line with a # the shell will try to interpret the line as a command.)

Preparing Assignments with script

Assignments in this class involve typing a sequence of Unix commands to the shell command line to perform some task(s). To allow me to see what the commands you use as well as the results that derive you will run a Unix command called script that copies everything you type and places it in a file as well as on the screen. This seems simple, but there is one thing that is different about using script than you are used to: script records keystrokes - it copies everything you type character by character. Thus, if you make a mistake and type a backspace, the erroneous character will be placed in the file, then the backspace, then the replacement character! Since you wont be printing your script file, it is fine so long as it displays correctly on the screen after you complete it. To make sure this is true, limit corrections when typing commands to the backspace character and do not use the arrow or TAB keys for command-line editing or history substitutions.

There are a handful of other things that you must be careful of when you are using script:

  1. script names its output file typescript or whatever other name you give it:

    script          #the output file is typescript
    script asmt01   #the output file is asmt01
            

    As with other Unix commands, script overwrites its output file. Be sure that you do not give it the name of a file you want! (A common mistake when students are writing a shell script is to give script the name of the shell script. It dutifully overwrites their shell script!)

  2. do not use command-line editing (the up-arrow) when you are typing commands to script. Command-line editing overtypes the line, making the result unreadable when it is printed.
  3. remember that you are using script, and don't forget to exit script when you are done. To exit script, simply type exit. It will respond that you are leaving script (see the example)
  4. Your script sessions should be clean and simple. Practice the assignment before you use script. Once you know the commands you need, start over using script and record the final version in the script session to hand in.
  5. If you must explain something while you are using script, simply type them to the shell as comments. (see the examples above)
  6. don't edit your script output file, and if you must cut and paste it, do it carefully. If your commands don't make sense, the assignment can't be graded.
  7. Never use a screen-oriented program, such as vi, nano, pico or more, when you are using script.
  8. If you must interrupt your script session you can add to the end of the output file (append to it) by using script -a scriptfilename. If you do not use the -a option, your script file will be overwritten.
  9. Never display your script output file using cat or more when you are creating it. This will create an infinite loop. (think about it!) You should only display the file after you have exited script.

Example Simple Assignment Session

Handing in the script output file

Never edit your output script file. It's better to get more practice and generate another file. Once you are content with your final script output, create a cover sheet and submit on Canvas