LAB 15: CONDITIONALS AND FILE TESTING
Rewrite checking. After checking whether the named user is in the /etc/passwd file, the program will check to see if the user is logged on. If so, the program will print all the processes that are running; otherwise, it will tell the user
<user> is not logged on.
The lookup script depends on datafile to run. In the lookup script, check to see if the datafile exists and if it is readable and writable. Add a menu to the lookup script to resemble the following:
[1] Add entry.
[2] Delete entry.
[3] View entry.
[4] Exit.
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. Now write the code for the Delete entry, View entry, and Exit functions. The Delete part of the script should first check to see if the entry exists before trying to remove it. If it 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. How do you check the exit status from the command line?
|