Assignment 5-A
Home ] Assignment 2 ] Assignment 3 ] Assignment 4 ] [ Assignment 5-A ] Assignment 5-B ] Assignment 6 ] Assignment 7 ] Errata / Updates ] Using Telnet ] Old Announcements ]
Updated:
1999-11-03 21:52

Home

Revised Oct 31: Assignment 5-A - UNIX - Section 040

This assignment is the first half of Assignment 5 for Section 040 - Ian Allen.

Hand in: The telnet log sheet from the last Hand In step in hard copy form.

Preparations:
    You must understand Chapter 4 to do Step 2 of this assignment.
    You must understand Chapter 5 to do Step 3 of this assignment.


Step 1.  (Readings in Chapter 4 and Chapter 5)

Use vi to create an answer file named c4+5answers containing answers to the questions listed in the Week 8 Reading Exercises.  Put your name on the first line of the file.  Answer only the following questions:
  • Answers to the Chapter 4 Reading Questions 4-2, 4-3, and 4-15 through 4-19.
  • Answers to the Chapter 5 Reading Questions 5-1 through 5-7, and 5-12 through 5-16.

Make sure that your name is located at the top of the file.

Step 2.  (Based on Chapter 4)

First: Before you begin this step, in your HOME directory, follow the text and Figure 4-6 (p.266) to create the directory tree named Projects.  Make sure that this Projects tree has two sub-directories and six files in it, exactly as it appears in the Figure.  Delete any files and directories under Projects that do not appear in Figure 4-6 on page 266.

Practice online to develop Unix command lines that perform the following tasks. When you have figured out the correct command lines, put the command lines that perform these actions in a new executable Unix script file named mytree.  Your commands must do the following steps:

  1. Create a directory under the /tmp directory and name it with your userid using this command line:
            mkdir /tmp/$USER
  2. Use ls to list the above directory to make sure that it exists and is empty.
  3. Using the Projects directory tree you created at the beginning of this step, copy the entire Projects directory tree to the directory you just created: /tmp/$USER You may need to look up online (in the Unix manual) how to use the Unix copy command to copy one entire directory to another directory.
  4. Using one command, list the entire /tmp/$USER directory tree, including all the subdirectories and files.  You should see two sub-directories and a total of six file names.  You may need to look up, in the Unix manual, the flag option to turn on a recursive listing of a directory contents and all its subdirectories.
  5. Use a Unix command to locate files by name.  The directory in which to look is the new /tmp/$USER directory you just created.  The name to look for is report3 - find this file and display its pathname.
  6. Remove the entire /tmp/$USER directory tree in one command.  (The entire directory must be removed.)
  7. Repeat Item B to verify that the directory no longer exists.  (You should get an error message about the nonexistent directory.)
Put the command lines that perform the above actions into the Unix script file, make it executable, and verify that the script file works exactly the same as if you had typed in the commands yourself.
Step 3.  (Based on Chapter 5)
 
Test out the following tasks and script files online.  When you have confirmed and tested the command lines and scripts that do each task, append the command lines from Item D, below, to the end of the mytree script file that you began in the step above.  (Make sure that everything still works when you execute the modified script file!)
  1. Create a script similar to the programA script file from Step 2 on page 355 of the text.  Make the following changes to the script from Step 2 on page 355:
    • replace the first line of the script with:  echo "---programA starts here ---"
    • replace the ps command line with:   ps -f
    • replace the fourth line of the script with:   echo "$0 PID is $$"
    • replace the name Gene Calhoun with your own name
    Save the modified script as programA and make sure it is executable by you.  Your script must have only six lines.  Test it.  Ensure that the modified script runs error-free.  Do not add the commands given in Step 4 on page 356.
  2. Make a copy of programA and name the new copy programB. Modify the new copy by
    • replacing the first line with:  echo "---programB starts here ---"
    • replacing the last two command lines with these four new command lines:
          echo "$0 I'm calling programA now"
          programA
          echo "$0 after call to programA"
          echo "$0 I'm done on `date`!"
    Save the modified script as  programB and make sure it is executable by you.  Your new script will have exactly eight lines.  Test it.  Ensure that the modified script runs error-free.  Pay attention to the different types of quotes being used (some quotes may be difficult to read, depending on your browser and font): DoubleQuote ", SingleQuote ', and BackQuote `
  3. Issue the following four command lines:
        echo "---Start testing processes of script files ---"
        ps -f
        echo "My shell PID is $$ and I'm calling programB"
        programB
    Ensure that the output of both scripts used in this step is error-free.  Pay attention to the quoting!
  4. When everything is working correctly, append the four command lines from the immediately preceding item to the end of the  mytree script file that you began in the previous step.  (Make sure that the script still runs without unexpected errors!)
  5. Save the two scripts you wrote for later use in Assignment 5-B.

Hand In:

Start telnet logging to record the following session on your A: diskette.  Perform only the following actions:
  1. Display your USER environmental variable.
  2. Display the date.
  3. Display the c4+5answers file created in Step 1.
  4. Display the completed mytree script of Steps 2 and 3.
  5. Execute the  mytree script to show that it works correctly and that it generates the correct output, without unexpected errors, for all the steps in this assignment.
Stop logging and print the telnet log file for handing in.  This one log file is the only thing you should hand in.


Web Author: Ian! D. Allen idallen@ncf.ca
Updated: 1999-11-03 21:52