Previous Section  < Day Day Up >  Next Section

LAB 18: FUNCTIONS

  1. Rewrite the systype program from Lab 16 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 BSD UNIX, the command is

    
    ps –aux
    
    

  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) Birthday
    
    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.

    Previous Section  < Day Day Up >  Next Section