LAB 32: LOOPS

 <  Day Day Up  >  

  1. Write a program called picnic that will mail a list of users, one at a time, an invitation to a picnic. The list of users will be in a file called friends . One of the users listed in the friends file will be Popeye .

    1. The invitation will be in another file, called invite .

    2. Use file testing to check that both files exist and are readable.

    3. A loop will be used to iterate through the list of users. When Popeye is reached, he will be skipped over (i.e., he does not get an invitation), and the next user on the list sent an invitation, and so forth.

    4. Keep a list with the names of each person who received an invitation. Do this by building an array. After everyone on the list has been sent mail, print the number of people who received mail and a list of their names .

    Bonus : If you have time, you may want to customize your invite file so that each user receives a letter containing his or her name . For example, the message might start:

     Dear John, I hope you can make it to our picnic.... 

    To do this your invite file may be written:

     Dear XXX, I hope you can make it to our picnic.... 

    With sed or awk , you could then substitute XXX with the user name. (It might be tricky putting the capital letter in the user name, as user names are always lowercase.)

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

    After the user has selected a valid entry, when the function has completed, ask the user if he or she would like to see the menu again. If an invalid entry is entered, the program should print the following:

     Invalid entry, try again. 

    The menu will be redisplayed.

  3. 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:

    1. Phone

    2. Address

    3. Birth date

    4. Salary

  4. Add the onintr command to your script using a label. When the program starts execution at the label, any temporary files will be removed, the user will be told Good “bye , and the program will exit.

 <  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