Subject 32547 UNIX Systems Programming, Autumn 2022
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit
Faculty of Engineering and Information Technology
Subject 32547 UNIX Systems Programming, Autumn 2022
Assignment
Description
This assignment is an individual programming assignment using Python. It addresses objectives 2 and 3 as listed in the Subject Outline document.
No limits apply to the number of lines of code of the program.
Assignments are to be completed individually (this might be checked with the use of anti- plagiarism tools such as Turnitin). You should not receive help in the preparation of this assignment, nor ask anyone else to prepare it on your behalf in any way.
Marks
The assignment corresponds to 30% of the total marks.
Submission
The completed assignment is due by 5:00pm of Monday 30 May 2022.
PLEASE PAY ATTENTION TO THE FOLLOWING SUBMISSION INSTRUCTIONS:
1. Your Python program has to be submitted on Canvas, following the “Assignments” menu and then the “Assignment” link by the due date. You can prepare your Python program anywhere you like, but probably the easiest option is to develop it in Ed STEM.
2. Please submit only your Python program, and nothing else (no data files).
3. Late submissions will be deducted one mark per day late; more than seven days late, the assignment will receive zero. Special considerations for a late submission must be arranged in advance with the Subject Coordinator.
Academic Standards
The assignments in this Subject should be your own original work. Any code taken from a textbook, journal, the Internet or any other source should be acknowledged. For referencing, please use the standard referencing conventions (http://www.lib.uts.edu.au/help/referencing).
Marking Scheme
Mark Range |
|
30 |
All requirements of the assignment are met. The submitted program can be executed by the lecturer “as is” and produces the requested output. |
24-29 |
The program works correctly with any valid file and for all options, but its execution experiences some minor problems. |
18-23 |
The program does not work as expected with one of the options. |
0-17 |
This range goes from no submission at all (0 marks) to a submission which does not meet major requirements of the assignment. Examples: • the program does not work as expected with two or more options; • the program generates unhandled errors; • the program does not solve the assignment problem. |
The assignments will be marked within two weeks from the submission deadline or as soon as possible.
Important notes:
• Submission of this assignment is not compulsory to pass the subject; do not feel that you have to submit it “at all costs” and perhaps be tempted to seek unauthorised assistance.
• There are no minimum requirements on the marks on this assignment to pass the subject.
• This assignment must be your own work and you should not be helped by anyone to prepare
it in any way; your assignment may be tested with anti-plagiarism software that detects
superficial changes such as changing variable names, swapping lines of code and the like.
• The subject coordinator may ask you to describe your assignment in a “viva voce” in Zoom to
finalise your mark.
• Understanding the assignment specifications is part of the assignment itself and no further
instructions will be provided; on the other hand, whatever is not constrained you can
implement it according to your own best judgment.
Title: Crontab files with Python
“Crontab” files are files used by Unix to execute commands at scheduled times. In this assignment, you will write a Python program that reads a simplified version of a crontab file and outputs some summary information.
These are the specifications for your Python program:
1. It must be named crontab_summary.py
2. It must be invoked as:
python crontab_summary.py option crontab_file
The program must check that argument crontab_file exists, is a file and is readable. If not, it must print a message of your choice to the standard output and exit. The specifications for the crontab_file and option arguments are given below.
3. File crontab_file can have any arbitrary name (including the extension). It must be a file of text with the following format:
a. The file consists of an arbitrary number of lines (including, possibly, zero lines).
b. Each line must contain five fields separated by commas.
c. The five fields are: minute, hour, day, username, command.
d. The minute field is a string of characters representing an integer number that can take values between 0 and 59.
e. The hour field is a string of characters representing an integer number that can take values between 0 and 23.
f. The day field is a string of characters representing an integer number that can take values between 0 and 6, representing the day of the week from Monday to Sunday.
g. The username field is a string of characters of length between 1 and 32 characters that contains a username.
h. The command field is a string of characters of arbitrary length that contains a command line, possibly inclusive of options and other arguments.
The following example is the reference specification for the format of file crontab_file :
0,0,6,massimo,/home/massimo/backup
30,17,4,johnsmith,/home/johnsmith/data/backup
0,0,6,root,/usr/bin/find / -name a.out
0,0,2,massimo,/home/massimo/backup
0,0,6,massimo,/bin/rm /home/massimo/tmp/*
0,0,2,massimo,/bin/rm /home/massimo/tmp/*
Fundamental note: your program is not expected to verify that file crontab_file complies with the above specifications. It will only be tested with compliant files.
4. Your program can be invoked with option: -a. In this case, it must print all the command lines, one per line, in the order in which they appear in file crontab_file:
<first command line in appearance order>
<second command line in appearance order>
…
<last command line in appearance order>
Example with the crontab_file file given above:
Command line:
python crontab_summary.py -a crontab_file
Output:
/home/massimo/backup
/home/johnsmith/data/backup
/usr/bin/find / -name a.out
/home/massimo/backup
/bin/rm /home/massimo/tmp/*
/bin/rm /home/massimo/tmp/*
In the case in which file crontab_file is empty, your program must instead only print:
no crontab commands
5. Your program can be invoked with option: -u username. The format of argument username is the same of that of the username field. In this case, your program must print all the file lines with that username, preceded by a header line :
crontab lines for user username:
<first file line for user username>
<second file line for user username>
…
<last file line for user username>
Example with the crontab_file file given above:
Command line:
python crontab_summary.py -u massimo crontab_file
Output:
crontab lines for user massimo:
0,0,6,massimo,/home/massimo/backup
0,0,2,massimo,/home/massimo/backup
0,0,6,massimo,/bin/rm /home/massimo/tmp/*
0,0,2,massimo,/bin/rm /home/massimo/tmp/*
In the case in which the username is not present in crontab_file (including the case where the file is empty), your program must print:
no crontab lines for user username
6. Your program can be invoked with option: -t time. Argument time specifies a time in a minute:hour:day format, each field using the same format as the corresponding crontab file field, separated by the : character. In this case, your program must print all the file lines on
or after the given time, in the order in which they appear in file crontab_file. The output must follow this template:
crontab lines on or after time:
<first file line on or after time >
<second file line on or after time >
…
<last file line on or after time >
Example with the crontab_file file given above (this will show all the commands scheduled on or after 2AM of Wednesday):
Command line:
python crontab_summary.py -t 0:2:3 crontab_file
Output :
crontab lines on or after 0:2:3:
0,0,6,massimo,/home/massimo/backup
30,17,4,johnsmith,/home/johnsmith/data/backup
0,0,6,root,/usr/bin/find / -name a.out
0,0,6,massimo,/bin/rm /home/massimo/tmp/*
In the case in which no file lines are present in crontab_file on or after the specified time (including the case where the file is empty), your program must print:
no crontab lines on or after time
7. Your program can be invoked with option: -v. In this case, it must only print your name, surname, student ID and date of completion of your assignment, in a format of your choice.
Please note that argument crontab_file is still required.
8. No options can be used simultaneously. This means that your program must only be invoked with one of the options at a time.
9. If your program is invoked with any other syntax than those specified above, it must print a message of your choice to the standard output and exit.
Examples of incorrect syntax:
python crontab_summary.py -z crontab_file (i.e., wrong option) python crontab_summary.py -a (i.e., missing the argument file)
python crontab_summary.py -u crontab_file (i.e., missing the username argument)
2022-05-24