Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

this is a Linux assignment: Using a folder named module in home directory Create

ID: 3740207 • Letter: T

Question

this is a Linux assignment:
Using a folder named module in home directory

Create a BASH script that completes the following tasks:
Create a zipped tar file (*.tgz) of the module folder including all of its subfolders
Use the date command to name the *.tgz file in the following format:
[Your Student ID] Backup (MM-DD-YYYY).tgz
Example: ab12345 Backup (03-25-2018).tgz
WARNING: The BASH script MUST create a filename using the current date.
Use the pscp command to transfer the *.tgz file to a remote server
Format of the pscp command:
pscp -pw [password] [local filename] [username]@192.168.100.80:[remote folder]/
Username: user
Password: password
Remote Folder
Use test while you are testing the pscp command and BASH script
Change to backup when your BASH script is complete

Thanks

Explanation / Answer

The following script is a bash script with all the tasks that you have asked for If any thing is missing please let me know I will make it complete. I've written comments above every command so that you can understsand easily.

#Edit the student ID as per your choice

studentID="ab12345"

#todayDate is the current date

todayDate=`date +%m-%d-%Y`

#Make a string out of id backup and todayDate and concat them

tarFileName="$studentID Backup ($todayDate).tgz"

# echo $tarFileName

#Store the module folder path in direc variable

direc=$(pwd ./)

# Get the basename of the module folder

bn=`basename $direc`

echo "Your module directory is $bn"

#Go to the home directory

cd ../

echo "Making $tarFileName for directory $bn"

tar -cjvf "$tarFileName" $bn

#tar zipping is done here

echo "Please enter your password and username and remote folder path"

#Please edit the password and username and remote folder information

pscp -pw [password] $tarFileName [username]@192.168.100.80:[remote folder]/