[Solved] CSE391 Assignment 7-Shell Scripting

$25

File Name: CSE391_Assignment_7-Shell_Scripting.zip
File Size: 329.7 KB

SKU: [Solved] CSE391 Assignment 7-Shell Scripting Category: Tag:
5/5 - (1 vote)

This assignment focuses on Bash shell scripting. Electronically turn in file autograder.sh as described in this document. You will also want the support files from the Homework section of the course web site.

For this assignment, you will write a script autograder.sh that grades solutions to a hypothetical homework assignment. Youre given a set of students solution files, each of which is supposed to be named gettysburg.sh (though some students used the wrong file name), and your script will run each of them one at a time, examining the output to see if it matches the expected output. The output from a run of your program will look like this:

$ ./autograder.sh 50 Retro Grade-It, 1970s versionGrading with a max score of 50 Processing joshue joshue has correct outputjoshue has earned a score of 50 / 50 Processing dravir dravir has incorrect output (1 lines do not match) dravir has earned a score of 38 / 50 Processing joeblow joeblow has incorrect output (4 lines do not match) joeblow has earned a score of 30 / 50 Processing oterod oterod did not turn in the assignment oterod has earned a score of 0 / 50

To get started, download the hw7.zip from the course web site which should contain the following:

  • students/ : This directory contains a set of fake student solutions to examine. Within the students directory there are student folders and files such as:

students/joshue/gettysburg.sh students/oterod/GETTYSburg.sh students/zorahf/gettysburg.sh

Each students directory is supposed to contain a file representing that students homework solution (though some students have not turned in the file properly, so it may not exist or may have the wrong name).

Note that you are not targeting the specific students shown above; your code should not specifically mention names like zorahf or joshue. Your code should process all students in the students directory.

  • txt : This file contains the expected homework output. This is the text youll compare to each students output to see whether it is correct.

You will write a script autograder.sh that gives each student a score on the assignment. Your program should accept the maximum score as a command-line argument. For example, to run it with a max score of 50 points, you would type:

$ ./autograder.sh 50

If the user does not pass a value for the maximum points, your script should print the following error message and exit:

$ ./autograder.sh

Usage: ./autograder.sh MAXPOINTS

You do not need to check this argument for validity. If an argument is passed, you may assume it is a positive integer.

Processing Each Student:

If your script is passed an argument, it should assume that the current directory contains 1) a students/ directory whose contents resemble those in the sample files you have been given (containing one directory per student, each named with the students id) and 2) expected.txt. Your script will examine each student in the students/ folder as follows:

1 of 2

  • Run the students sh file, using the students folder as the working directory. (You may want to capture the students output into a file.) Note that the student script files may not have execute permission, so you should manually invoke bash to run them, such as: bash ./gettysburg.sh
  • Compare the students output against the expected output file using diff. Run diff so that it ignores all white space (explore the options for diff in the man pages). Count the number of lines that do not match. To simplify things, we will consider any line of diff output containing a < or a > to count as 1 line of unmatched content. Produce output in this format:

joshue has correct output

or:

smith has incorrect output (8 lines do not match)

For each unmatched line, deduct 5 points from the students score. For example, if the diff output has 4 lines that have < or >, the student should lose 20 points. If the student loses more points than there are points in the assignment, the student should receive 0 points.

(Hint: You can look for each of < and > separately and total them, or search for lines that have either one.)

  • Output each students score on the assignment. If a student jones has no differing lines of output, the score output for that student would be:

jones has earned a score of 50 / 50

If student davis has 3 differing lines of output (-15), the score output would be:

davis has earned a score of 35 / 50

If the student did not turn in the program or incorrectly named the file, the student gets 0 points on the assignment. (See the various if tests from lecture such as -d, -e, etc. to see whether files exist or have various properties.) If the user lewis did not turn in a proper gettysburg.sh file, you would output the following:

lewis did not turn in the assignment

See the course web site for several complete sample output runs of the program.

You may assume that no students program tries to do anything evil to your computer, such as erasing all your files. You may also assume that students code will not lock up and get stuck in any sort of infinite loop. It is okay if your autograder.sh script creates temporary files while doing its work, though if so, you should remove them as you go along.

Development Strategy (suggested):

  • Make your script print the introduction with the max points command line argument.
  • Make your script able to simply output the names of all of the students to be processed.
  • Make your script able to simply run each students sh program and show its output on the terminal.
  • Make your script able to diff the expected output against each students sh output.
  • Make your script compute and print the score for each student.
  • Make your print the suggested usage and exit when an argument is not passed for the max points.

Hints:

  • Some tasks in your script will involve running Unix commands and capturing their output with $( ). Since such commands run silently as their output is being captured, consider simply running the command first to see that the command is running properly and producing results that you expect.
  • Remember to use echo statements to output partial results, computations, commands, etc. to verify them.

Your script should work if placed in any directory containing expected.txt and a students/ directory. Do not hard code in a specific directory on your machine or your home directory on attu. This is important for grading!!

Each Linux/Unix box can be slightly different; for full credit, your commands must be able to work properly on any of the CSE virtual machine image, attu, or on the CSE basement lab computers.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CSE391 Assignment 7-Shell Scripting
$25