Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Please provide UNIX BASH Script for below problem, thank you so much in advance. Incase of any confusion, the language needed is UNIX Bash, similar

Please provide UNIX BASH Script for below problem, thank you so much in advance.

image text in transcribed

Incase of any confusion, the language needed is UNIX Bash, similar to below:

*** EXAMPLE CODE - DO NOT USE IN ANSWER IN PLEASE ***

#!/usr/bin/bash echo

Hello this script is running on the server called $HOSTNAME

echo the current time is: `date` echo

if [ -z $1 ]; then

echo You forgot to supply an argument on the command line!

exit 1

fi

1) For this portion of the lab, you are asked to create an "assignment submission tool" as a shell script. The script will create a ZIP file for you of the contents of the directory you specified on the command line. This ZIP file is what you will submit to blackboard for grading. See below for a quick description of the zip command line parameters. You are required to write the script in such a fashion to have it create the zip file for you using the proper naming convention. If you recall from the syllabus, I require that all submissions be in the form: LastName_FistName_DirectoryName.zip. Since your login name on the server is unique, and consists of firstnamelastname, you may use the environment variable SUSER (or \$LOGNAME) as an alternative if you so desire. Since there are no environment variables which individually contain your first or last names, you will need to create these variables within your script (should you choose the proper naming convention). It would be considered "bad form" to hardcode text strings into your solution. Variable names are preferred just in case you move this script to another machine which uses a different naming convention. You are expected to use variables for these and NOT hard code them into the ZIP filename. Of course, if you want, you could create the environment variables yourself in your bashrc (but then you would have to test for their initialization in the script to not wind up with NULLs). Your script should accept a command line argument. This should be the name of the subdirectory you are going to ZIP-up for submission. Command line parameters are accessible within your script as $1,$2,$3 To prevent issues when unpacking everyone's work for grading, it is important that your ZIP command include the full path to the target sub-directory. To accomplish this you MUST use the environment variable \$HOME as part of the ZIP command line. Ensure that you script created the ZIP file in the HOME directory of your account. If it creates it in the directory you are trying to ZIP up, the ZIP file itself will be corrupted. You may find the \$PWD environment variable useful in this endeavour. Make sure the script is properly documented, is executable and that you identify, using the established UNIX convention discussed in class, the proper shell interpreter it is intended to run under. How to use ZIP: (see the man page for more details) zip zipfilename [list of files or directories to include in the zipfile] e.g.: jacques@UBU64vm: \$ zip -r jacquesabeland_lab1.zip home/jacquesabeland/lab1 verb LOGNAME 1st parameter HOME 1st parameter the -r flag for the zip command causes the program to RECURSE into subdirectories should they exist. Omitting this flag will result in a ZIP file that only contains the "directory" file and not its

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions