Assignment 6
Home News & Discussion Notes Windows 95 Unix Assignment 4 Assignment 5-A Assignment 5-B Assignment 6 Assignment 7
Updated:
2000-11-18 16:25

Assignment 6 - UNIX

This assignment is for sections taught by Ian Allen.

Hand in:
One printed and hand-annotated telnet session log file in hard copy form.  For full marks, follow the Assignment Submission Standards.  In particular, make sure you use Courier font and annotate your output (see below) before you hand it in.
Preparations:
You must complete the work in the previous Chapters (1, 2, 3, 4, 5, 6, 7, 8, and 13) as well as Chapter 22 in your Unix text before doing this assignment.

Step 1.  (Readings in Chapter 22)

Use the vi text editor to type the answers to the following Chapter Reading/Study Exercises into the file named  my22answers in your home directory.  Number each answer clearly.  You will find the Chapter Exercises under the Unix button on the course page.
    Put your name and your Algonquin e-mail address at the top of the file.
    Answer the Chapter 22 Exercises 22-1 through 22-8.

Put your name and your Algonquin e-mail address at the top of this file.  Number each answer clearly.

Step 2.  (Based on Chapter 22)

Develop the checkuser script file (see pages 912-921 of the text).  Debug it until it works without errors.  When it work without errors, try the script with the following quoted command line argument containing blanks:
checkuser "This argument contains blanks"

Does the script generate error messages?  Fix the script so that it does not generate error messages when the argument contains blanks or other special characters.  (See "Quoting Multiple-Word Arguments" on page 950.)

Step 3.  (Based on Chapter 22)

Develop the scriptarg script file (see pages 918-919 of the text).  Debug it until it works without errors.  When it work without errors, try the script with the following command line arguments (pay careful attention to the quotes):

scriptarg "Does this work with" "*" "?"

Does the script handle the special characters in the arguments correctly?  Are they correctly echoed in the output?  Fix the script so that it does not expand special characters in the arguments when it runs.  (See "Quoting Multiple-Word Arguments" on page 950 and "Quoting Special Characters" on page 960.)

Step 4.  (Based on Chapter 22)

Work through Sections 22.5-22.9 (see pages 923-948 of the text) and create the menu shell script.  (Make sure you name your menu shell script with a name that isn't already a Unix command or alias.  If you find that there is already a menu command or alias, name your script something else, e.g. menu1 .)

Note: Read carefully section 22.9 on the use of indentation in your script!  Follow the indentation examples used in the text.  Scripts that are not structured properly cannot be understood or marked.  Your finished script should follow the indentation pattern of the scripts given starting on page 984.

Test each of the six menu entries, in order.

To test menu item 4, enter this file name: /etc/resolv.conf
To test menu item 5, enter the name of your profile file: .profile
(If you don't have a profile file, create one first.  You might put VISUAL=vi into it.)

Step 5.  (Based on Chapter 22)

Based on the knowledge learned in the above three script files, write a script file named menu2 that will loop to present menu selections to the user.  Create five menu selections that perform the following actions:

  1. Display the first 4 lines of  /etc/passwd    (Note the number of lines!)
  2. Display the last 3 lines of   /etc/passwd    (Note the number of lines!)
  3. Search in file  /etc/passwd  for lines matching a pattern and display the lines found.  The user will be prompted for the pattern to search for.  Test this menu entry with your userid as the pattern.  Test it again with a single asterisk  * as the pattern.  (There are about five lines in the ACADAIX password file that contain asterisks.)
  4. Search in file  /etc/passwd  for lines that do not contain a pattern and display only a count of the number of lines that do not contain the pattern.  (Select the correct command options to count the lines and to select the lines that do not match the pattern.)    The user will be prompted for the pattern to search for.  Test this menu entry with the pattern: ksh (counts 15 lines that do not contain  ksh).  Test it again with the digit zero as the pattern (counts 9 lines that do not contain the digit zero).
  5. This last menu selection should exit the script.

The script file should state in the header comments:

the name of the shell that will execute the script (first line!)
the script name
your name and Algonquin email userid
the date of creation of the script
a short description of the function of the script

Step 6.  (Creating the Telnet Log File)

You need to have done all the readings, completed all the prerequisite Chapters, and completed all previous steps of this Assignment to do this logging Step.

Login to Unix and then turn on telnet logging to record the following Unix session on your A: diskette or on your N: drive.  When asked to display the contents a file or script, use the  cat command.  (For full marks, do not use an editor or any commands that paginate the file, since the pagination mis-formats the display of the file in the log.)  Perform the following actions for the log file: 

  1. Set your shell prompt to be your Algonquin userid.
  2. Display the contents of your HOME environment variable.
  3. Display the current date.
  4. Display the contents of the file my22answers that you created in Step 1.
  5. Display the contents of the completed checkuser script of Step 2.
  6. Execute the checkuser script with no command arguments.  Type in your own login name when your script prompts you to enter a login name.
  7. Execute the checkuser script with a single command line argument that is your login name.
  8. Execute the checkuser script with the following command line (pay attention to the use of quotes) and ensure that there are no error messages in the output:
    checkuser "This argument contains blanks"
  9. Display the contents of the completed scriptarg script of Step 3.
  10. Execute the scriptarg script with the following command line (pay attention to the use of quotes) and ensure that there are no error messages in the output:
    scriptarg "Does this work with" "*" "?"
  11. Display the contents of the completed menu script of Step 4.
  12. Execute the menu script of Step 4 and test each of the six menu items, in order, using the testing data given in Step 4.
  13. Display the contents of the completed menu2 script of Step 5.
  14. Execute the menu2 script of Step 5 and test each of the five menu items, in order, using the testing data given in Step 5.  (Some menu items require more than one test.)
  15. Display the current date.

Turn off telnet logging.  Print the Telnet log file using a monospace (Courier) font.  Choose the font size so that the contents of your answer file looks neat and prints without line wrapping.

Step 7.  (Annotating the Telnet Log File)

 Annotate your printed Telnet log file output by hand as follows:

  1. Take a pen or marker and draw long, page-width lines between each of the numbered actions you performed in the previous step.
  2. Write in (using pen or marker) the number of the action beside each of the actions.  Use the action numbers given in the previous step.
  3. Highlight or underline each of the Unix command lines you typed to the shell to do the actions in the previous step.  Do not highlight the output of the command lines.  Highlight only the Unix command lines that you typed in.

There is only one telnet session log file to hand in.  It comes from the Telnet Log File step.  Do not log or hand in anything else other than the one log file from the Telnet Log File step.  Make sure you annotate the log file by hand as required in the Annotating step.  

Web Author: Ian! D. Allen idallen@ncf.ca
Updated: 2000-11-18 16:25