-------------------------- Practice Unix/Linux Script - whodater.sh -------------------------- -IAN! idallen@ncf.ca All scripts written must conform to the script_checklist.txt checklist. All user input (arguments or via "read") must be validated before being used. Do not process bad or missing input data! Write an executable shell script named whodater.sh that will do the following actions (in the order given below): 1. Verify that there are exactly two command line arguments; otherwise, exit with an error message. (i.e. Exit if there are not two arguments.) 2. Put the first argument into a variable named mydir. 3. Put the second argument into a variable named myfile. 4. Verify that the path named by the mydir variable is a directory; otherwise, exit with an error message. (i.e. Exit if the path is not a directory.) 5. Verify that the path named by the mydir variable is writable; otherwise, exit with an error message. (i.e. Exit if the directory is not writable.) 6. Verify that the path named by the mydir variable is searchable; otherwise, exit with an error message. (i.e. Exit if the directory is not searchable.) 7. Put the file pathname $mydir/$myfile into a variable named newfile. (Do not create this file yet.) 8. Verify that the file named by the newfile variable is zero size or nonexistent; otherwise, exit with an error message. (i.e. Exit if non-empty.) 9. Put the current date into the file named by the newfile variable. Exit with a non-zero exit status if the command fails. 10. Put the pathname for a temporary file into a variable named tmp. Use the process ID of the current process in the pathname. The pathname of the temporary file should be under the /tmp directory. (Do not create the file yet.) 11. Put a sorted list of online users into the temporary file named by the tmp variable. Exit with a non- zero exit status if the command fails. 12. Append the contents of the temporary file (the list of online users) to the file that contains the date (created in a previous step). Exit with a non-zero exit status if the command fails. 13. Also append this exact sentence to the same file: The number of users is XXX. where XXX is the number of lines in the temporary file. 14. Remove the temporary file.