代写 Scheme software University of Technology Sydney

University of Technology Sydney
Faculty of Engineering and Information Technology
Subject: 32547 UNIX Systems Programming, Spring 2019 Assignment
Description
This assignment is an individual programming assignment using Perl. 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 Friday 18 October 2019.
PLEASE PAY ATTENTION TO THE FOLLOWING SUBMISSION INSTRUCTIONS:
1. Your Perl program has to be submitted on UTSOnline, following the “Assignments” menu and then the “Assignment” link by the due date.
2. Please submit only your Perl program, and nothing else.
3. Late submissions will be deducted one mark per day late, more than seven days late the assignment will receive zero. Special consideration, for late submission, must be arranged in advance with the Subject Coordinator.
1

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. 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.
2

Title: Process information with Perl
In this assignment, you will write a Perl program that reads from a file similar to the output of Unix’ command ps (information about the processes running on a Unix computer). These are the specifications for your Perl program:
1. The file containing your program must be named pslog.pl
2. Your program must use the following syntax:
pslog.pl option argument_file
Your program must check that the argument_file argument is an existing and readable file. If not, it must print a message of your choice to the standard output and exit. The format for file argument_file and the values for the option argument are described below.
NB: Please do not worry about the path to your program: we will ensure that its directory is in the path when we mark it. We will also ensure that your program is executable.
3. File argument_file can have any arbitrary name. It must be a file of text with the following format:
a. The file consists of an arbitrary, yet reasonable, number of lines (including, possibly, zero lines). Each line corresponds to a process.
b. Each line must contain four fields separated by one or more space characters.
c. The four fields are: process ID, terminal, time and command name.
d. Field process ID is a string of characters representing an integer between 0 and 32768. If the string’s length is less than 5 characters, this field is padded to the left with space characters (see the examples below).
e. Field terminal is a string of minimum 1 / maximum 8 characters representing the terminal associated with the process.
f. Field time is a string of 8 characters representing the cumulated CPU time in format hours(2 digits):minutes(2 digits):seconds(2 digits). Examples: 66:45:52; 00:00:00; 00:05:00; 08:11:01; 99:59:59.
g. Field command name is a string of characters with the name of a command (no spaces allowed).
The following example should be regarded as the reference specification for the format of file argument_file:
728 ?
2809 tty4
21367 pts/17
21375 pts/17
22825 ?
25369 pts/0
00:05:45 kmirrord
00:00:00 getty
00:00:00 sh
21:59:07 alexnet.py
00:00:11 apache2
00:00:00 sh
Important note: your program does not need to verify that file argument_file complies with the specifications. You can simply assume that the file meets all the specifications given above.
3

Suggestion: After reading a line from the file, try to use function split(‘ ‘) to split it into its four fields.
4. Your program can be invoked with option: -a. In this case, it must print all the command names present in the file, one per line, in the order in which they appear in the file.
Example with the example argument_file given above: Command line:
pslog.pl -a argument_file Output:
kmirrord
getty
sh
alexnet.py
apache2
sh
In the case in which file argument_file is empty, your program must instead only print:
No commands
5. Your program can be invoked with option: -t. In this case, it must print all the unique terminals present in the file (each terminal only once), one per line, in the order in which they first appear in the file.
Example with the example argument_file given above: Command line:
pslog.pl -t argument_file Output:
?
tty4
pts/17
pts/0
In the case in which file argument_file is empty, your program must instead only print:
No terminals
6. Your program can be invoked with option: -s time threshold. In this case, it must print all the lines of file argument_file where the value of field time is greater than or equal to the value of argument time threshold, in the order in which they appear in the file. The format of argument time threshold is the same as that of field time.
4

Example with the example argument_file given above: Command line:
pslog.pl -s 00:02:00 argument_file Output:
728 ? 00:05:45 kmirrord
21375 pts/17 21:59:07 alexnet.py
In the case in which no values of field time meet the requirement (including the case of an empty file), your program must print:
No processes above threshold
7. Your program can be invoked with option: -n. 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 argument_file is still required.
8. 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:
pslog.pl -Z argument_file pslog.pl -u
Please be reminded that:
 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 by anti-plagiarism software that detects superficial changes such as changing variable names, swapping lines of code and the like.
 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.
5