Question: For your second assignment, you will write a shell script that builds on those skills that you developed so far this semester and with the
For your second assignment, you will write a shell script that builds on those skills that you developed
so far this semester and with the first assignment. However, instead of an analysis tool, you will build a
system administration tool that provides functionality for file backup and restoration. You will need to
determine characteristics of files, perform operations on files in this case, compression and be able to
add and extract files from an archive file in tar format
Rather than providing an interactive menu, this time you will provide for all functionality of the script
by evaluating the command line its options, aka flags, possibly with arguments; and positional
parameters and environment variables. This might make the script more appropriate for use via cron or
remote execution.
The name of the archive file to use create modify, or query will be passed to the script on the
command line. Additionally, the following flags and actions will be supported:
b : backup a copy of filename from the filesystem into the archive, but only if it
is not already in the archive or if it is newer than the version in the archive. If filename does
not exist in the filesystem to be archived, silently exit with error code
r filename : restore filename to the filesystem from the archive; however if a version of the
file already exists in the filesystem and that existing file is older than the version from the
archive, then extract the file from the archive to the current directory as filenamenewer. If
filename does not exist in the archive, silently exit with status code
c : gzip compress the file being backed up not the archive, just the file as indicated by the b
flag before adding to the archive; calculate the percentage saved by compressing that file and
append a line consisting of the following comma separated fields:
the current system date and time, filename, and the saved amount as a percentage
to the logfile The logfile will have be named, either, the value of the A LOG environment
variable if it is set or assignlog if the environment variable ALOG is not set
If an invalid flag an option not b r nor c is passed to the program, print "Invalid Option" to stderr and
exit with a return status code of
Graduate students will also need to provide the additional following functionality.
If the c option is provided, but the b option is not, then exit silently with return status code of
Only when processing the b flag, if the file to add to the archive is not readable or if the archive
is not writeable print the message "Archive access failure" to stderr and exit with return status
code
Only when processing the r flag, if the archive file to restore from does not exist or is not
readable, print the message "Archive retrieval failure" to stderr, and exit with return status code
Your script submission must be a text file uploaded to Brightspace for full credit it must be posted on script should be bash file for opensuse linux patform vi script.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
