Command Line Assignment 3

Due 02 Oct 2015, 10AM.

40 Points

This is a work sheet assignment, all work is to be done on this page. This means this page is due in class at start of class on the due date.

You have two sets of commands. See below for constructing these.

The first set, s1, s2, s3, s4, and s5 will print their name and issue a successful return code of 0 on completion.

The other set, f1, f2, f3, f4, and f5, will print their name and and issue a non-zero return code equal to the number portion of their name on completion.

You will be assigned a set of 20 5-command sequences which mix &&, ||, ;, and () between the commands.

Click here to get the list of command sequences. Print this out.

In a work directory on hopper/turing, create the two sets of commands and run each of the sequences. For each of the success commands, s1, s2, s3, s4, and s5, copy the following bash shell script into a file. Make it executable.

If you want, you can create a single file and hard link the 4 additional names to the original file.

      #!/bin/bash
      echo $0
      exit 0

For each of the fail commands, f1, f2, f3, f4, and f5, copy the following bash shell script. If you want, you can create a single file and hard link the 4 additional names to the original file.

      #!/bin/bash
      echo $0
      rc=`echo $0 | cut -c4`
      exit $rc 
For each problem on the work sheet, first, see if you can predict which command will run. Then enter the command sequence in hopper or turing as it is shown. and run it.

As they run, they will print out their names. For each of the commands, indicate which ran by circling it on the worksheet and write the value of the exit status after the "echo $?" on the work sheet.

Make sure you put your Name on the work sheet.

Turn the worksheet in to me or your TA.