LAB 58: CONDITIONALS AND FILE TESTING

 <  Day Day Up  >  

  1. Rewrite the checking script from Lab 57. After checking whether the named user is in the /etc/passwd file, the program will check to see if the user is logged on. If so, the program will print all the processes that are running; otherwise it will tell the user

     <user> is not logged on. 

  2. Use the let command to evaluate a set of grades. The script will ask the user for his or her numeric grade on an examination. (Use declare “i .) The script will test that the grade is within the allowable range between 0 and 100. If not, the program will exit. If the grade is within the range, the user's letter grade will be displayed (e.g., You received an A. Excellent! ). The range is as follows :

    A (90 “100) B (80 “89) C (70 “79) D (60 “69) F (Below 60)

  3. The lookup script from Lab 57 depends on datafile in order to run. In the lookup script, check to see if the datafile exists and if it is readable and writable. Add a menu to the lookup script to resemble the following:

     [1] Add entry [2] Delete entry [3] View entry [4] Exit 

    You already have the Add entry part of the script written. The Add entry routine should now include code that will check to see if the name is already in the datafile and if it is, tell the user so. If the name is not there, add the new entry.

    Now write the code for the Delete entry , View entry , and Exit functions.

    The Delete part of the script should first check to see if the entry exists before trying to remove it. If it does, notify the user; otherwise, remove the entry and tell the user you removed it. On exit, make sure that you use a digit to represent the appropriate exit status.

    How do you check the exit status from the command line?

 <  Day Day Up  >  


UNIX Shells by Example
UNIX Shells by Example (4th Edition)
ISBN: 013147572X
EAN: 2147483647
Year: 2004
Pages: 454
Authors: Ellie Quigley

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net