UNX510 Professor: Shahdad Page 1 of 5UNX510 – Unix BASH Shell ScriptingAssignment 1Objective: To gain experience with elementary scripting techniques.Due date: July 18, by midnightValue: 10% of final course markSpecifications: You are to write a Bash shell script, on the Matrix server, which willshow the permissions of a directory and all the directories in its path. Write a utilitycalled showDir that satisfies the following requirements:1. Usage: showDir [ dir-name ]showDir will show a formatted listing of permissions of a directory, and of all thedirectories in its path, starting from the root directory. The directory name may bespecified including absolute or relative paths as necessary. If no directory nameis specified, the default will be the current working directory.showDir will work for directories only. The script will print an appropriate errormessage if the number of arguments passed to it is invalid, or if the directoryname specified is not the name of a valid existing directory. If an error messageis issued, then the script should end with an exit status of 1 (one). Otherwise, itshould end with an exit status of 0 (zero).showDir will highlight the directories which do not have execute permission forother users. This is particularly useful for checking paths in websites, as shown inthe examples below.Here are examples of showDir error messages (filename “dir1” exists, “dir2”does not exist):$ cd ~User/public_html/unx510/assign2$ showDir dir1 dir2Usage: showDir [ dir-name ]$ showDir dir2 dir1Usage: showDir [ dir-name ]$ showDir dir2showDir: dir2 is not a valid directory nameHere are some sample runs of the showDir script:UNX510 Professor: Shahdad Page 2 of 5$ cd ~User/public_html/unx510/assign2$ showDirOwner Group Other Filename—– —– —– ——–d r w x r – x r – x /d r w x r – x r – x homed r w x – – x – – t Userd r w x – – x – – x public_htmld r w x – – x – – – unx510d r w x – – x – – x assign2$ showDir dir1Owner Group Other Filename—– —– —– ——–d r w x r – x r – x /d r w x r – x r – x homed r w x – – x – – t Userd r w x – – x – – x public_htmld r w x – – x – – – unx510d r w x – – x – – x assign2d r w x – – x – – x dir1$ showDir ..Owner Group Other Filename—– —– —– ——–d r w x r – x r – x /d r w x r – x r – x homed r w x – – x – – t Userd r w x – – x – – x public_htmld r w x – – x – – – unx510$ showDir .hidden_dirOwner Group Other Filename—– —– —– ——–d r w x r – x r – x /d r w x r – x r – x homed r w x – – x – – t Userd r w x – – x – – x public_htmld r w x – – x – – – unx510d r w x – – x – – x assign2d r w x – – x – – – .hidden_dirUNX510 Professor: Shahdad Page 3 of 5$ showDir ~User/public_html/unx510/assign2Owner Group Other Filename—– —– —– ——–d r w x r – x r – x /d r w x r – x r – x homed r w x – – x – – t Userd r w x – – x – – x public_htmld r w x – – x – – – unx510d r w x – – x – – x assign2Note that showDir does not clear the screen before displaying the pathinformation.2. Ensure that the format of your output matches the output format in the examplesabove exactly.3. Implement proper argument validation .4. Do not include any functionality in showDir other than that specified above.5. Use only UNIX capabilities that have been covered in this course.6. awk should not be used in this assignment, nor should ${…} string manipulation.7. Here are some hints and tips that may help you with this assignment:A. Here’s some pseudo-code for one approach to this script. Besidesprocessing any arguments, checking for errors, and printing the headerlines, the script can be divided into two main parts: Find the absolute path of the required directory, which was passedas an argument or defaulted to the current directory:Change to the specified directory, if there is oneThe absolute path of the required directory is the value of thePWD variableLoop through each level in the absolute path, starting at the rootdirectory (see Tip B):Change to the directory at the current loop levelTurn highlighting on if the current directory does not haveexecute for others (you can use “grep” for this)Print out the file-type/permissions string for the level,formatted properly (see Tip C)Turn highlighting off B. To split the path up into the different levels, the easiest way is to translateeach “/” to a space.C. To print out the file-type/permission string properly formatted, cut out thestring and pipe it through three “sed” substitute commands.UNX510 Professor: Shahdad Page 4 of 58. Marking scheme: If your script can’t run the assignment examples correctly,with output EXACTLY duplicating the sample output formats, then theassignment may be a resubmit. Marks will be deducted for errors in the followingareas:a. Comments as specified: name, section, etc.b. Output format as specified.c. Error messages as specified.d. Error messages redirected properly.e. Proper exit status.f. Handles directory names at any level.g. Handles relative and absolute pathnames.h. Uses /tmp directory and $$ for temporary files (if used).i. Temporary files should be deleted (if used).Assignment Submission1. Assignment 2 is due on July 18,2021 @ 11:59pm.2. Submitted assignments MUST contain the student’s OWN solution to theassignment.3. Your assignment MUST run on the Matrix server.4. Ensure that your script is self-contained in one file, called showDir5. At the beginning of your script, include comments with the following informationformatted neatly, and reflecting accurate information for you.# Assignment 2# Course: UNX510# Family Name: Student# Given Name: John# Student Number: 123-456-789# Login name: jstudent# Professor: Shahdad Shariatmadari# Due Date: July 18, 2021## I declare that the attached assignment is my own work in# accordance with Seneca Academic Policy. No part of this# assignment has been copied manually or electronically from# any other source (including web sites) or distributed to# other students.UNX510 Professor: Shahdad Page 5 of 5What to Submit:1) Please submit the script that you developed during this Assignment.2) Please submit a recorded-video which explains how you did the lab and demonstrate yoursolutions. This will give everyone the opportunity to present their solution. Please record avideo (2~10 minutes) with the following contents: Introduce yourself Show/demonstrate how your assignment works. Explain your code (walkthrough), how you design it ( a quick/detailed walk-through ofthe programming code , running the commands in Matrix) Speak about challenges that you faced during this Assingment. Evaluate yourself. Have you implemented all requirements of the lab? how do youevaluate yourself out of 10 for this Assingment?NOTE: You can record the video using some screen-capture software (like OBS :https://obsproject.com/ ) or your cellphone. To submit the video:o You can upload the video on the youtube (you may make it unlisted) and submitthe link here.o You can also directly upload the video to the BB.
