LAB 30: CONDITIONALS AND FILE TESTING

 <  Day Day Up  >  

  1. In the lookup script, ask the user if he or she would like to add an entry to the datafile . If yes or y :

    1. Prompt the user for a new name , phone, address, birth date, and salary. Each item will be stored in a separate variable. You will provide the colons between the fields and append the information to datafile .

    2. Sort the file by last names . Tell the user you added the entry, and show the added line preceded by the line number.

  2. Rewrite checking from Lab 29. After checking whether the named user is in the /etc/passwd file, the program will check to see if he or she is logged on. If so, the program will print all the processes that are running; otherwise it will tell the user the following:

     <user> is not logged on. 

  3. The lookup script depends on datafile in order to run. In the lookup script, check to see if datafile exists and if it is readable and writable.

  4. Add a menu to the lookup script to resemble the following:

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

  5. 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 datafile and if it is, tell the user so. If the name is not there, add the new entry.

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

  7. The Delete entry part of the script should first check to see if the entry exists before trying to remove it. If the entry does not exist, 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.

  8. 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