Unix Assignment and a
Script-Based Grading Assistant

In section 1, is an example of a homework assignment which I emailed to my students in the Introduction to Unix class in Spring 1999. Basically, students were asked to create a certain directory structure and certain files within it. They had to set up the files with certain permissions as well. My problem with grading this type of assignment is that I am locked out of the student accounts so I cannot see that they have done it correctly unless I am right there when they are logged onto the system. This is because I encourage all my students to set the security settings for their accounts to keep others from copying their work (but that locks me out as well). The solution was to take advantage of something else I did early in the semester, when I had the students set up their accounts so that they could automatically run commands (or a command SCRIPT) that I created in a particular directory which I controlled. I created a script called s99_lab3 and told students to run that script as the last step of the assignment. Why is this the solution? Because the student is sending the results to me rather than me trying to get them on my own. Thus, the student's own "permission settings" apply (and usually one has permission to look at their own work).

In section 2, I show the actual command script which I created for this purpose. It is not important to understand the details. Basically, it generates output summarizing what the student created (including the dates when different items were generated... important for verifying that electronic cheating is unlikely) and then emails that to me. I even allow the student to review the output first and decide if they really want to send it. If any errors are made then it should be obvious so that they can fix it and retry.

In section 3, I show an example of what I get by email from the student. In this case I ran a hypothetical example in which the student did not do everything correctly. I changed all instances of the username to johndoe for this illustration.


1. The Assignment

Spring 1999 Intro to Unix Lab 3 (10 points) On page 84 of the textbook you will see a file structure that I want you to create. First, however, I want you to create a directory called chap7ex (spelled EXACTLY as shown). Thus the structure will be as follows: [your home directory] | | chap7ex /|\ \ / | \ \___ / | \ \___ / | \ \ Cal fun jul99 summer99 / \ / \ 1999 Months / \ / \ june99 aug99 The 1999 file should contain the entire 1999 calendar. The summer99 file should contain the calendars for June, July, and August of 1999 (one after the other). The fun file should contain the word "fun" in banner size. The others contain individual month calendars as the name suggests. For all of this you will use the cal and banner commands. Set the permissions on all of these (using chmod) as follows: rwxr--r-- chap7ex rwxr-xr-x Cal rwxr----- fun rw-r--r-- jul99 rw-r--r-- summer99 rw------- 1999 rwxr-x--- Months r--r--r-- june99 r--r--r-- aug99 Finally, you are to type the following command when you are done which sends it all to me. s99_lab3

2. The Script

echo Do you want to see what you will be sending first? \(n or y\) read answer if [ $answer = "y" ] then cd ( echo "User: $LOGNAME"; echo "Date: `date`"; echo; echo echo -n "======================================="; echo "======================================="; ls -lR chap7ex; echo -n "================================== fun "; echo "======================================="; cat chap7ex/fun; echo -n "================================ jul99 "; echo "======================================="; cat chap7ex/jul99; echo -n "============================= summer99 "; echo "======================================="; cat chap7ex/summer99; echo -n "================================= 1999 "; echo "======================================="; cat chap7ex/Cal/1999; echo -n "=============================== june99 "; echo "======================================="; cat chap7ex/Cal/Months/june99; echo -n "================================ aug99 "; echo "======================================="; cat chap7ex/Cal/Months/aug99; echo -n "======================================="; echo "======================================="; ) 2>&1 | more echo; echo; echo Do you now want to send all this to jsjones? \(n or y\) read answer if [ $answer = "y" ] then echo Okay, it is being sent to jsjones as requested... else echo Okay, it is NOT being sent. exit fi fi cd ( echo "User: $LOGNAME"; echo "Date: `date`"; echo; echo echo -n "======================================="; echo "======================================="; ls -lR chap7ex; echo -n "================================== fun "; echo "======================================="; cat chap7ex/fun; echo -n "================================ jul99 "; echo "======================================="; cat chap7ex/jul99; echo -n "============================= summer99 "; echo "======================================="; cat chap7ex/summer99; echo -n "================================= 1999 "; echo "======================================="; cat chap7ex/Cal/1999; echo -n "=============================== june99 "; echo "======================================="; cat chap7ex/Cal/Months/june99; echo -n "================================ aug99 "; echo "======================================="; cat chap7ex/Cal/Months/aug99; echo -n "======================================="; echo "======================================="; ) | mailx -s s99_lab3 jsjones

3. The Returned Result (example)

Date: Mon, 8 Mar 1999 13:07:06 -0600 (CST) From: johndoe To: jsjones Subject: s99_lab3 Mime-Version: 1.0 User: johndoe Date: Mon Mar 8 13:07:05 CST 1999 ============================================================================== total 6 drwxr-xr-x 3 johndoe users 1024 Feb 12 10:57 Cal -rw-r--r-- 1 johndoe users 153 Feb 12 09:50 fun -rw-r--r-- 1 johndoe users 401 Feb 12 10:56 summer99 chap7ex/Cal: total 6 -rw-r--r-- 1 johndoe users 1729 Feb 12 10:57 1999 drwxr-xr-x 2 johndoe users 1024 Mar 8 11:49 Months chap7ex/Cal/Months: total 4 -rw-r--r-- 1 johndoe users 1 Mar 8 11:49 June1999 ---------- 1 johndoe users 1 Mar 8 11:49 aug99 ================================== fun ======================================= ####### # # # # # # # # ## # ##### # # # # # # # # # # # # # # # ## # #### # # ================================ jul99 ======================================= cat: Cannot open chap7ex/jul99: No such file or directory ============================= summer99 ======================================= June 1999 S M Tu W Th F S 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 July 1999 S M Tu W Th F S 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 August 1999 S M Tu W Th F S 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 ================================= 1999 ======================================= 1999 Jan Feb Mar S M Tu W Th F S S M Tu W Th F S S M Tu W Th F S 1 2 1 2 3 4 5 6 1 2 3 4 5 6 3 4 5 6 7 8 9 7 8 9 10 11 12 13 7 8 9 10 11 12 13 10 11 12 13 14 15 16 14 15 16 17 18 19 20 14 15 16 17 18 19 20 17 18 19 20 21 22 23 21 22 23 24 25 26 27 21 22 23 24 25 26 27 24 25 26 27 28 29 30 28 28 29 30 31 31 Apr May Jun S M Tu W Th F S S M Tu W Th F S S M Tu W Th F S 1 2 3 1 1 2 3 4 5 4 5 6 7 8 9 10 2 3 4 5 6 7 8 6 7 8 9 10 11 12 11 12 13 14 15 16 17 9 10 11 12 13 14 15 13 14 15 16 17 18 19 18 19 20 21 22 23 24 16 17 18 19 20 21 22 20 21 22 23 24 25 26 25 26 27 28 29 30 23 24 25 26 27 28 29 27 28 29 30 30 31 Jul Aug Sep S M Tu W Th F S S M Tu W Th F S S M Tu W Th F S 1 2 3 1 2 3 4 5 6 7 1 2 3 4 4 5 6 7 8 9 10 8 9 10 11 12 13 14 5 6 7 8 9 10 11 11 12 13 14 15 16 17 15 16 17 18 19 20 21 12 13 14 15 16 17 18 18 19 20 21 22 23 24 22 23 24 25 26 27 28 19 20 21 22 23 24 25 25 26 27 28 29 30 31 29 30 31 26 27 28 29 30 Oct Nov Dec S M Tu W Th F S S M Tu W Th F S S M Tu W Th F S 1 2 1 2 3 4 5 6 1 2 3 4 3 4 5 6 7 8 9 7 8 9 10 11 12 13 5 6 7 8 9 10 11 10 11 12 13 14 15 16 14 15 16 17 18 19 20 12 13 14 15 16 17 18 17 18 19 20 21 22 23 21 22 23 24 25 26 27 19 20 21 22 23 24 25 24 25 26 27 28 29 30 28 29 30 26 27 28 29 30 31 31 =============================== june99 ======================================= cat: Cannot open chap7ex/Cal/Months/june99: No such file or directory ================================ aug99 ======================================= cat: Cannot open chap7ex/Cal/Months/aug99: Permission denied