OPS435: Assignment #1
HAND-IN REQUIREMENTS:
This assignment consists of 2 parts (stages). The following table displays the due date and a brief description of each of these stages:
Stage |
Description |
Due Date |
---|---|---|
1 |
Create a shell script that prompts a user for existing question and answer files (exit program if either of those files do not exist), otherwise, display questions, prompt the user for the answer, and indicate if user's answer is CORRECT or contains SOME ERRORS. |
Monday June 7, 2010 |
2 |
Modify the existing shell script (created in stage 1) to incorporate dialog boxes using the Zenity command, and to use if / else statements to replace the && and || logical operators.
|
Wednesday June 23, 2010 |
OVERVIEW / REQUIREMENTS:
STAGE
#1:
You have a friend whose child needs extra help in mathematics. Since that person loves to use the computer, you have decided to write a shell script called
takeQuiz.bash that will display mathematical questions from a file, allow the individual to enter their answers, and to indicate if their answers are all CORRECT or if they have SOME ERRORS. ATTENTION: Immediately set permissions to only allow the owner of the newly-created file to view contents (eg. chmod 700 ~/takeQuiz.bash). If you don't, others may be able to guess and view the contents of your file, and this would be considered giving the answer to another student!
Your shell script works as a stand-alone command without arguments. When the shell script is run, the shell script will greet the user by their full name. Then the script will prompt the user for a questions file pathname and then for an answers file pathname. If either of these files do NOT exist, then the shell script with a false value (no messages given).
HINT: You can instruct the shell script to exit with a false value by issuing the exit command with a non-zero number as its argument. On the other hand, if both files exist, indicate they exit and proceed with the program.
The shell script will then display the questions from the valid questions file, and allow the user to enter the answer (with answered values separated by a single space). This answer needs to be compared to the answers file to see if identical or different. There are many methods to acheive this result, but try to use redirection and a method to compare files... If there are no differences, then indicate CORRECT, otherwise indicate SOME ERRORS.
Refer to the Sample Runs for Stage #1 (displayed below)...
ADDITIONAL NOTES FOR STAGE 1:
Here are some other important notes or warnings:
SAMPLE RUNS (Commands or shell script name is in boldface. Assume current user's name is Murray Saul)
cat nofile cat: nofile: No such file or directory cat questions.txt 1 x 4 = 3 + 7 = 4 / 2 = 5 - 9 = 1 + 1 = cat answers.txt 4 10 2 -4 2 ./takeQuiz.bash Welcome to Take Quiz, Murray Saul! Please enter questions file pathname: nofile # Note: Script exits since "nofile" file pathnames doesn't exist! ./takeQuiz.bash Welcome to Take Quiz, Murray Saul! Please enter questions file pathname: questions.txt Questions file Exists Please enter answers file pathname: nofile # Note: Script exits since "nofile" file pathnames doesn't exist! ./takeQuiz.bash Welcome to Take Quiz, Murray Saul! Please enter questions file pathname: questions.txt Questions file Exists Please enter answers file pathname: answers.txt Answers file Exists Here are the questions: 1 x 4 = 3 + 7 = 4 / 2 = 5 - 9 = 1 + 1 = Write each answer separated by a space Answer Here -> 4 10 1 -4 2 SOME ERRORS, Please practice again ./takeQuiz.bash Welcome to Take Quiz, Murray Saul! Please enter questions file pathname: questions.txt Questions file Exists Please enter answers file pathname: answers.txt Answers file Exists Here are the questions: 1 x 4 = 3 + 7 = 4 / 2 = 5 - 9 = 1 + 1 = Write each answer separated by a space Answer Here -> 4 10 2 -4 2 CORRECT
STAGE
#2:
You are going to make your shell script more "user-friendly" by using the Zenity command. This command allows you to create dialog boxes to display, or obtain information from a user. Think of the zenity command as a replacement for your echo and read statements.
Refer to this link for examples how the Zenity command works: [ How to Use Zenity ]
Also, you can use the man pages to learn how the zenity command works.
You MUST replace && and || logical operators with if / else statements.
ADDITIONAL NOTES FOR STAGE 2:
Here are some other important notes ,suggestions, or warnings:
WARNING:
Since the "Zenity" command produces a dialog box, you CANNOT run this command remotely connected from home!
Therefore, there are 2 approaches to working on this assignment:
This means you should complete your assignment as soon as possible!
SAMPLE RUNS FOR STAGE 2:
Here is a YouTube video to show you how this shell script will work:
(You can also view full screen, pause and play (replay) these Youtube videos)...
ASSIGNMENT SUBMISSION INSTRUCTIONS:
You MUST submit your assignment from your Matrix account (no exceptions). You MUST run the programs below to submit your assignment stages (no exceptions). The following table displays which commands to run for submitted stage1 and stage2 (when available).
STAGE |
SUBMISSION INSTRUCTIONS |
SUBMISSION PROGRAM PATHNAME (in Matrix) |
---|---|---|
STAGE #1 |
/home/murray.saul/ops435/435-a1-s1-submit |
|
STAGE #2 |
/home/murray.saul/ops435/435-a1-s2-submit |
GRADING
Shell scripts are to be submitted from your Matrix account from the submission scripts displayed above – no exceptions.
If you do not submit your script on time, there will be a 10% penalty.
Late assignments will carry a penalty of 10% per day. Since assignment is submitted electronically: weekends count!.
If your
script
is not functional when tested, or produces too many incorrect
answers, it will receive a mark of zero and must be resubmitted with
in 7 days.
Once resubmitted, such assignments can receive a
maximum of 55%.
Every assignment will be checked for plagiarism. If any copying is discovered, both students will receive a mark of zero and a "Dishonesty Report" will be entered in both student's files. Students that have been caught sharing materials with other students or placing themselves in situations where student can access their work will receive a "Warning" and this warning will be entered in the student's file.
Good Luck :)