CSCI 330 Fall 2001
C-Shell Programming Assignment
Due 1 November 2001 Thursday
General purpose
Write a c-shell script that will mail the assignment[s] specified to your
professor and TA. The program will ask for the assignment number and
check it for valid value. It will then ask for your section number and
check for valid value. Next it will ask for a list of files to email the
appropriate people. It will check for the existence of those files before
proceeding. Then mail each file specified, include on subject line the
assignment id.
Pseudo-code with hints and requirements
Create an endless while loop
Prompt the user for the assignment number, descibe the range
of valid values.
Get the value from the user.
Use grep to test for only numeric input.
If non-numeric
Print message and go back to top of this input loop
Check for valid numeric value using the switch structure
If value is one of the valid values
break out of loop (continue after end of loop)
Else if value is out of range
Print message and go to top of input loop
End of while
Prompt the user for the section number they are in. Remind them of which
TA is assigned to which sections. Greg Noth (z018079) Sections 1 & 5,
Olga Urban (z987658) Sections 3 & 7. You must code the program to allow
any of the sections (and thus either of the TAs) to be selected.
Get input (Section number) from user and test for valid value using grep.
While input not valid
Prompt user for the name of all files related to current assignment.
The user will issue all names on a single input line which will be
assigned to an array.
Set an error code variable to 0
Using the appropriate for loop to retrieve each filename one at a time,
test each file for the following conditions and report on any problems.
Follow the general structure describe below.
If file does not exist
Print appropriate message
Set the error code variable to 2
Break out of loop
Else if file is a directory
Print appropriate message
Set the error code variable to 3
Break out of loop
Else if file is a regular file
If the file is readable
Add the filename to a file of valid filenames
Use the filename save_files."pid" where pid is the current
process id.
Else
Print appropriate message ( no read access )
Set the error code variable to 4
Break out of loop
Else
Print appropriate message( unrecognized filetype )
Set the error code variable to 5
Break out of loop
If the return code is greater than zero
Terminate the program with the return code set by test
Show the user the list of checked file names
Ask the user if she/he wishes to mail the files
If the user wishes to continue
Use the for command to separately mail each file in the file list.
In the mail command sequence (use mutt or mailx) include a subject
line with the Course id (csci330) and the assignment id.
Mail the assignment to both the teacher and the appropriate TA
Also record in the file "log_file", the name of the assignment, the
names of the files mailed, the date of mailing and the recipients
Terminate the program with an error code of 0
Else
Terminate the program with an error code of 1