Assignment #5

 

  1.  (100%)Assuming you are a grader to grade students’ C or shell programs altogether. Write a shell script (Bourn/C/Korn/Bash shell) called as5.sh which creates a menu for grading all students' programs (either written in C language or shell scripts). All students' folders are located in /home/cshing/public_html/310/Example/tmp.

The menu must contain the following 4 options:

    1. Compile and Run a C Program: After choosing this option, it prompts for your filename (assuming you type in yourfilename, do not put .c extension in) to be compiled, and make a copy of the source program and save it as yourfilename.txt. If no syntax error, it will execute and the result will be stored in the default filename (as yourfilename_out.txt). If syntax error occurs, the error will also be stored in the default filename (yourfilename_out.txt) and viewed in option 3.
    2. Interpret and Run a shell Program: After choosing this option, it prompts for your filename (assuming you type in yourfilename, do not put .sh extension in) to be interpreted, and make a copy of the file called yourfilename.txt. If no syntax error, it will execute and the result will be stored in the default filename (yourfilename_out.txt). If syntax error occurs, the error will also be stored in the default filename (yourfilename_out.txt).
    3. Generate Report: After choosing this option, it prompts user to enter filename (with extension either .c, .sh or .txt) and then invokes vim editor to pull out the same file from each student folder to view it. So the grades can be added into the output file for viewing.
    4. Quit.
  1. Note: You must assume that anyone can run your shell script in his/her own account. You cannot create files in your own account only. Therefore in your script you need to check whether a temporary directory called tmp exists in  the current running directory. If not, create it to hold all the directories copied  from /home/cshing/public_html/310/Example/tmp and then copy all files that user needs to the corresponding directories in order to compile and run your program.
  2. (Extra Credit 10% for students who has a correctly running as5.sh) Rewrite the previous one using Perl/PHP/Python and stored as as5.pl/as5.php/as5.py and provide all necessary README file for running instruction.

Assignment 5 Hint


Instructions for Submitting as5.sh and as5.pl/as5.php/as5.py