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, a.k.a. 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 (1) it
is not already in the archive or (2) 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 7.
-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 14.
-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 2 LOG environment
variable (if it is set) or assign2.log (if the environment variable A2LOG 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 3.
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 6.
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 15.6 linux patform vi script.
For your second assignment, you will write a

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!