CS计算机代考程序代写 scheme Page 1 of 8

Page 1 of 8
KIT213 Operating Systems
Semester 2, 2021
Assignment – UNIX Shell Programming
(20% of your KIT213 final result)
Due at 3PM Friday Week 12, 8 October 2021
There are three (3) shell programming tasks in this assignment. This is an
individual assignment. You are required to make a directory named
kit213agn under your home directory (on ictteach), and use kit213agn
as your working directory for this assignment.
Assignment submissions will be marked by the KIT213 tutors on ictteach.
If you write and test your scripts elsewhere it’s your responsibility to ensure
that your scripts run correctly on the Linux system (ictteach).
IMPORTANT NOTE: Your assignment files will need to be submitted into a
directory named kit213submit (to be created in your ictteach home
account). The kit213submit directory/folder will be created for you
automatically by the ictteach system administrator close to the submission
time – do not create it yourself as this will cause your assignment to not be
submitted correctly. If the kit213submit folder does not exist two weeks
before the assignment deadline, please advise the Unit Coordinator
immediately (Shuxiang. .au). Without a kit213submit
folder, you will not be able to submit your assignment.

Page 3 of 8
Task B
Write a shell script (to run on the Bourne shell) that runs an infinite loop to
check every 3 seconds to report on who logs into and who logs out of a UNIX
system. Without loss of practical significance of this little utility, we can
ignore multiple logins from the same user during a time period of less than 3
seconds.
You would need to research some of these UNIX commands: cut, sort, cmp.
Your script for this task must be named log.sh. The following is a sample
output of the script (It is OK that the script leaves behind a temporary file
when it is finally interrupted). The $ is the shell prompt.
$ ./log.sh
The current time is:
Thu August 26 12:18:28 AEST 2021
The current users are:
abc
rv0
sxu
tgray
No user has logged in/out in the last 3 seconds.
No user has logged in/out in the last 3 seconds.
User rsmith has logged in.
User jchen has logged in.
No user has logged in/out in the last 3 seconds.
User abc has logged out.
User rv0 has logged out.
No user has logged in/out in the last 3 seconds.
… … … … … … … …
(Note: The second line of the output must show the current time when this script is
run.)
Page 4 of 8
Task C
A telephone directory file, teledir.txt, maintains records in the form:
name:number
where number is of the form xxxxxxxx. The following is an example of such
telephone directory file:
John Smith:63243333
Sally Williams:62269988
Dan Roberts:63365577
Ray Jackson:62278989
Devise a shell script (to run on the Bourne shell) that accepts one or two
arguments which could be:
(1) the name or number. If it exists in the directory, then the entry should
be displayed.
(2) the name and number. The entry is displayed if it exists and is added if
it does not exist in the directory.
A validation check for the name or the number has to be performed. A valid
name can contain only letters and spaces. A valid phone number must contain
8 digits, and the first digit of a valid phone number must not be zero. In the
beginning of your script, you need to verify that the telephone directory file
(teledir.txt) exists under the current directory.
Your script for this task must be named phone.sh. Here are sample outputs
of your script. The $ is the shell prompt.
$ ./phone.sh john
John Smith:63243333
$ ./phone.sh Smith
John Smith:63243333
$ ./phone.sh Adams
Name does not exist
$ ./phone.sh Smith12
Invalid name
$ ./phone.sh “John Smith”
John Smith:63243333
$ ./phone.sh “Eric Adams”
Name does not exist
$ ./phone.sh “Joe Adams1”
Invalid name
$ ./phone.sh 62269988
Sally Williams:62269988
$ ./phone.sh 99999999
Number does not exist
$ ./phone.sh 09999999
Invalid phone number
$ ./phone.sh 1234567890
Invalid phone number
$ ./phone.sh “John Smith” 63243333
John Smith:63243333
$ ./phone.sh “John Smith1” 63243333
Invalid name
$ ./phone.sh “John Smith” 03243333
Invalid phone number
$ ./phone.sh “Joe Adams” 63335656
New entry Joe Adams:63335656 added
Page 6 of 8
For All Your Scripts
You must
• Include your full name, student ID, and a brief introduction of what
the script does in all your shell scripts, as a comment in the beginning
of each script.
• Make your scripts run on the Bourne shell, regardless of which shell
the user of your scripts is currently on.

Add in-line comments to help other people understand your scripts.

Use “\n” where appropriate to make the output of your scripts more
readable.

Note that your script structure and layout are also important as they
will be marked as part of the assessment process.
Submitting Your Assignment
You must submit a single folder named kit213agn which contains the
following five (5) files, electronically to the kit213submit folder which will
be created for you in your ictteach account (do not create this
kit213submit folder yourself, see below for more details):
compr.sh log.sh phone.sh ff teledir.txt
(Please make sure that your kit213agn folder only contains the five files as
listed here, when you are ready to submit them)
To submit your assignment, follow these three steps:
1). Ensure that both your kit213agn folder and your kit213submit folder
are stored right under your home directory;
2). Run the following commands to copy your kit213agn folder into your
kit213submit folder (the $ is the shell prompt):
$ cd (This takes you back to your home directory from anywhere)
$ cp -r kit213agn kit213submit (This copies your assignment folder into
your kit213submit folder. The option -r is important)
$ ls -l kit213submit (This verifies that your assignment folder is now in your
kit213submit folder)
$ ls -l kit213submit/kit213agn (This verifies that your assignment files are
now in your kit213submit folder)
3). Immediately use your mobile phone (or a snipping tool installed on your
laptop) to make a screenshot of your secure shell window (such as PuTTY
window) and submit the image file to KIT213 MyLO (under Assessments, then
Assignments), as proof of your assignment submission. Use your name and ID
number as the image file name, for example, Smith_John_012345.jpg. If
your assignment files are copied into the kit213submit folder by the
deadline, you do not receive any penalty if this image file is slightly late.
Page 7 of 8
IMPORTANT NOTE: The kit213submit directory/folder will be created
for you automatically by the ictteach system administrator close to the
submission time – do not create it yourself as this will cause your assignment
to not be submitted correctly. If the kit213submit folder does not exist two
weeks before the assignment deadline, please advise the Unit Coordinator
immediately (Shuxiang. .au). Without a kit213submit
folder, you will not be able to submit your assignment.
If your assignment is late then you should submit your files to the
kit213late folder. The late folder will be created automatically after the
due date and will be available for one week only. Please note, we do not
accept a partial submission (such as for Tasks A and B) by the deadline, with
the remaining part (such as Task C) submitted after the deadline. If you do
this, then only your partial submission made before the deadline would be
marked.
Need Help?
You are encouraged to seek assistance from your lecturer after you have seriously
thought about the assignment. Please note that we can provide general advice,
however, we will not help you write any code, nor will we help you debug.
(See next page for the assignment marking scheme)
Page 8 of 8
Appendix: KIT213 Assignment Marking Scheme
Script compr.sh (for each item there are only 3 possible marks: 100% or 50% or 0%)
Item
Mark
Execution of the shell script
Script runs as expected (2). Script runs but not as expected (1). Script does not run (0)
2
Correctly use bzip2, gzip, and zip to compress the file
2
Correctly display an output table which shows the specified information
2
The columns of the table are left-aligned as specified
2
Script log.sh (for each item there are only 3 possible marks: 100% or 50% or 0%)
Item
Mark
Execution of the shell script
Script runs as expected (2). Script runs but not as expected (1). Script does not run (0)
2
Display every 3 seconds “No user has logged in/out in the last 3 seconds.” when
this is true
2
Correctly report users who have logged in
2
Correctly report users who have logged out
2
Script phone.sh (for each item there are only 3 possible marks: 100% or 50% or 0%)
Item
Mark
Execution of the shell script
Script runs as expected (2). Script runs but not as expected (1). Script does not run (0)
2
Validation check for an 8-digit telephone number
2
Validation check for a name
2
Correctly display the entry when an existing valid name and valid number are
supplied as an argument
2
Correctly adding new entries (name:number) to the existing telephone directory
file
2
Others (for each item there are only 3 possible marks: 100% or 50% or 0%)
Mark
Shell scripts structure and layout
Clear and tidy (2). Somewhat messy but understandable (1). Messy (0)
2
Include name, ID, and brief introduction in all scripts
2
Appropriate in-line comments
2
Assignment Total:
/32