CSC128: Introduction to Linux

Project 2 - User interaction and control structures


Tools: sleep, read, shift, if statements, while loop

Assignment

For this Lab you will write a shell script that:

  1. Tests to see that the user input at least 1 command line argument, if the user did not enter at least 1 command line argument, you need to tell them that they need to try again and enter at least 1 command line arg and exit with an exit code of 1.
  2. Asks the user to enter his/her name and then returns to him/her the name that they entered and a greeting.
  3. It will then stop and tell them the number of command line arguments they entered and the name of the program that they are running even if they copied it and changed the name, and press enter to continue.
  4. The script will then count down the number of command line arguments that are left, printing one per second to the screen reporting how many command line argumnts are left. (use the shift builtin in a loop). So the screen would do a countdown 6 5 4 3 2 1 (if I had entered 6 six command line arguments).
  5. When the last command line argument has been reached (shifted over to $1) the program will tell the user the value of the command line argument in a statement such as "The last command line argument that you entered is ______ .(whatever it's value was is to be printed there.)

Classroom sections will show me your program in class for a grade. Again make sure that the filename is: ~[username]/bin/[username]proj2.sh

Grading Structure:
  • 50 points total
  • (15 pts) script named [yourusername]proj2.sh placed in your ~/bin directory on time. You will be sure that I can execute the script.
  • (10 pts) uses the BASH shell and correct syntax, and has no undesirable side effects. I should NOT be able to change this file.
  • (25 pts) correct report information