Linux script求解

【Linux script求解】Linux Coursework
For the Linux coursework, you must write a Linux script that will complete a set of tasks.
This is worth 5% of this module and is open book. There should be sufficient time in the labs
to complete the task, but if you are finding it difficult, then you may need to work on it in
your spare time. Note that this is a coursework and will be different from the normal lab
sessions in that it is expected that this will be your own work. The lab assistants will still be
there to answer general questions but will not be able to help you with the script itself. You
can still discuss the problem with your classmates, but in the end, the solution must be your
own. REMEMBER you must save your script outside of the lab machine in each lab as your
data may be lost if you don’t make a more permanent copy.
Task 1 (39 marks)
The task set for this year’s Linux coursework is to sort and process a collection of files. In the
Unix section on Moodle in the Coursework folder, you will find a zip file called un_
sorted_files.zip containing multiple files of many different types. You must first download
this file and copy it across to your home directory in the Linux virtual machine. I would also
advise creating a scripts directory as in Lab part 4.
Processing the Files
From here onwards, all tasks (in this Task 1 section) must be completed by your Linux
Script ONLY. Unzip the file using the unzip command. You will need to look up the options
for this command yourself using the techniques that you have learned in the labs. Your task
is to write a script called process_files that will accept from the user as command line
arguments a series of 3 strings representing file types. You must then create 4 directories –
one for each file type and one for any files that do not match any of the file types - and
separate the files into these new directories then return some information about these files
to the user. For example if the user types
process_files jpg gif docx
Your script will sort the jpg/jpeg, gif and doc/docx files into their appropriate directories
and the remaining files into a miscellaneous directory, before processing them. Note: All
jpg/jpeg should be in the same jpg directory, all doc/docx in the same docx directory.
Output
Your script needs to output 5 different files. In each of the directories that you create, you
should create a file that contains a list of all the files in that directory sorted by size order.
Also, in the main directory, your script should output a file that contains a label for each
directory and the files in each directory sorted in reverse alphabetical order. This file should
look something like this
…. These are the jpg files….
last_file_alphabetically.jpg
next_ last_file_alphabetically.jpg
…. All the gif files ….
last_file_alphabetically.gif
next_ last_file_alphabetically.gif
….. all the docx files …..
etc.
This is a difficult file to construct, so full marks will go in this section to replicating that file
format. You might need to create several temporary files to complete the task. You will still
get some marks for this section by creating a summary file of some description.
Your final scripting task is to provide a separate clean-up script that will remove the files and
directories that you created from the virtual machine (make sure you have a backup copy of
your files and scripts before testing it).
Describe Your Code and Personal Reflection
Using the comment keyword # in your script allows you to add a comment that the
interpreter ignores. This lets you add a more human-readable dimension to your script. ie.
cp file123 directory20 # This line copies file123 into directory20
The text after # adds no functionality but explains what the command does. Comment your
script to describe how it works. Finally, at the bottom of your script include comments, that
is a single paragraph of a) some personal reflection on the working state of your script, b)
how you approached the task, c) what you have learned and d) how this would affect how
you would approach a similar task in the future.
Task 2 (11 marks)
a) Install and Configure Apache Web Server on Ubuntu. Follow all the steps in the link
provided on Moodle (you may use different resources if you wish). Take a screenshot
of each step. Make sure your name is visible on the screenshots. When you set up
your domain name, make sure the html file includes a title message such as
“Welcome to the Programming and System development Course!” Also make sure to
include a message in the body that displays your name and student ID.
b) Enable SSH on your Ubuntu system. Verify that the installation was successful and
SSH service is running. Again, make sure you take screenshots of each step to include
in your file.
Saving and uploading your files
You must upload a zipped folder (your_name.zip, for e.g Mireilla_Bikanga_Ada.zip)
containing 4 files on Moodle. The first file is your main script and personal reflection
(process_files). The second file is the clean-up script (clean-up). The third file is a word
document (your_name1.docx for e.g. Mireilla_Bikanga_Ada1.docx) containing screenshots
of your outputs when the script is run (Task 1) – displays content of the directories and
content of the files. The fourth file is a word document (your_name2.docx for e.g.
Mireilla_Bikanga_Ada2.docx) containing all the screenshots for Task 2 a) and b). The
screenshots must show your name (see example below).
Marking
The Coursework will be marked out of 50 with the distribution of marks as below
Task 1 (39 marks)
A) Unzip the file and make directories for each of the file types requested and a miscellaneous
directory.
4
B) Use of command line arguments for file types 2
C) Separate the files into their appropriate directory. 4
D) Provide a list of all the files in each directory sorted by size 5
E) Provide a labelled summary file of all the files in each directory sorted in reverse alphabetical
order
8
F) Provide a separate script to clean up all the files from the zip file 3
G) Personal reflection paragraph 4
H) Comment your code to explain the process 4
I) Style and presentation for Task 1 3
J) Screenshots demonstration of Task 1 2
Task 2 (11 marks)
k) Install apache sever 1
L) Configure apache server 6
m) Enable and verify SSH on your Ubuntu system 2
n) Screenshots demonstration of Task 2 (a and b) 2

    推荐阅读