LAB 61: FUNCTIONS

 <  Day Day Up  >  

  1. Rewrite the systype program from Lab 59 as a function that returns the name of the system. Use this function to determine what options you will use with the ps command in the checking program.

    The ps command to list all processes on AT&T UNIX is

     ps ef 

    On UNIX/BSD UNIX/Linux, the command is

     ps aux or ps aux  [9]  

    [9] Using the leading dash with UNIX will produce a warning. See the man page. Without the leading dash, Linux displays only user 's processes.

  2. Write a function called cleanup that will remove all temporary files and exit the script. If the interrupt or hangup signal is sent while the program is running, the trap command will call the cleanup function.

  3. Use a here document to add a new menu item to the lookup script to resemble the following:

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

    Write a function to handle each of the items in the menu. After the user has selected a valid entry, and the function has completed, ask if the user would like to see the menu again. If an invalid entry is entered, the program should print

     Invalid entry, try again. 

    and the menu will be redisplayed.

  4. Create a submenu under View entry in the lookup script. The user will be asked if he or she would like to view specific information for a selected individual:

     a) Phone b) Address c) Birth date d) Salary 

  5. Use the trap command in a script to perform a cleanup operation if the interrupt signal is sent while the program is running.

 <  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