Quiz 3 (Due in or before class, 4th week)

(Remember: your shell is not "sh", please type "sh" or "bash" before attempting any of the interactive examples from the text.)

Question 1: Shell programming 1
Write a shell script that verifies that the password file makes sense. Have it announce duplicate logins and UIDs, check to make sure each user has a password, and that every ones home directory and shell exists. If you can't remember what the fields are in the passwd file, see passwd(4). For detecting duplicates, examine the utilities uniq, comm, cmp. You are welcome to use temporary files, provided that you take precautions to make sure you don't overwrite someone elses file.

Solution 1:
Here is an example verify-passwd script.

Question 2: Shell programming 2
Write a shell script (call it "run-on-all-logins") that will cycle through all of the user logins and run another command (provided at run time as $1) on each user login. An example interaction might be here. Write a shell script (call it "count-procs") that counts the number of processes a user has. Have it take the login name as $1. Use these two shell scripts to give you a list of how many processes each user has running on a given machine. Assume the BSD style "ps" (available in /usr/ucb on Solaris).

Solution 2:
Here is an example run-on-all-logins , and an example count-procs.