Previous Section  < Day Day Up >  Next Section

LAB 14: CONDITIONAL STATEMENTS

  1. Write a script called checking that will do the following:

    1. Take a command-line argument: a user's login name.

    2. Test to see if a command-line argument was provided.

    3. Check to see if the user is in the /etc/passwd file. If so, it will print

      
        Found <user> in the /etc/passwd file.
      
      

    4. Otherwise, it will print

      
      No such user on our system.
      
      

  2. In the lookup script, ask the user if he or she would like to add an entry to datafile. If the answer is 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 him or her the line preceded by the line number.

    Previous Section  < Day Day Up >  Next Section