CSC128: Introduction to UNIX

Project 3


Concepts:
BASH shell (bash) programming
variables
arguments
control structures
Functions
test (for file types)
User Interaction


Description:
Create an executable BASH shell (bash) shell script that will:
  • Require exactly 2 command line arguments and calls the error_function passing the error message as an argument to the function that says You must enter Exactly 2 command line arguments, please try again: The error function takes the argument passed to it, prints it and then exits with an exit code of 1.
  • Tell the user the values of the two command line arguments that they entered and ask for a Y or y or N or n to confirm that they do or do not want to continue. If they did do a typo, and the user enters an N or n meaning that they did make a mistake and wish to quit, then call the error function passing the ermessage to the function with a different message saying Program exiting because you said you had a typo, Please try again:. If the user enters something other than a yYNn then call the error function passing the message "You did not enter a Y or an N please try again"
  • Tell the user if the command line arguments they entered were indeed files in the directory that the user specified. If one or both files did not exist, call the error function and give the message: Sorry, one or both files not located, please try again: .
  • Then test to see if each file that exists is a regular type of file or if one or the other is a directory type of file. If one of the files is a directory type of file, call the error function and display this message: Sorry, one or both of the files that you entered was a directory, please try again:
  • In all cases an argument is passed to the same error function that prints the text that is outlined in bold on this page.
  • Tell the user if they own or do not own each of the files that they entered. (Hint: run man test to figure out how to test for these things.)
  • Tell the user which file is newer of the 2 file names they entered.

Grading Structure:

  • 50 points total
  • Classroom sections will show me your program in class for a grade. Again make sure that the filename is: ~[username]/bin/[username]proj3.sh
  • (15 pts) script named ~[yourusername]/bin/[yourusername]proj3.sh It must be executable by me but not be writable by me, it must also be on time..
  • (10 pts) uses bash and correct syntax, and has no undesirable side effects.
  • (25 pts) correct report information
Tools:
test, if-then-elif