Question: Using information about bash conditional expressions found in http://www.gnu.org/software/bash/manual/html_node/Bash-Conditional-Expressions.html, write a bash shell script called 06-permissions that will: i. Take exactly one command-line parameter, a

Using information about bash conditional expressions found in http://www.gnu.org/software/bash/manual/html_node/Bash-Conditional-Expressions.html, write a bash shell script called 06-permissions that will: i. Take exactly one command-line parameter, a path to a single directory or file. It will display a USAGE message if something other than one parameter is used, and then exit with an error code of 1. ii. The script will display information about the permissions of that file or directory. (See below for what is to be displayed.) iii. If the file/directory does not exist, the script will exit with an error code of 2. iv. If the script runs successfully it will exit with an error code of 0. It is strongly suggested that you validate your script against the paths included in the Examples section of this problem. Examples: (Note that in the sample output below a 1 means true and a 0 means false.)

input: $ 06-permissions ~turk/NetworkingClass/first

# exits with error code of 0

output: thePath=[/home/turk/NetworkingClass/first]

exists=1

directory=1

regFile=0

size=1

read=0

write=0

execute=0

input: $ 06-permissions ~turk/NetworkingClass/scripts

output: thePath=[/home/turk/NetworkingClass/scripts]

exists=1

directory=1

regFile=0

size=1

read=1

write=0

execute=1

input: $ 06-permissions ~turk/NetworkingClass/scripts/sampleNames

output: thePath=[/home/turk/NetworkingClass/scripts/sampleNames]

exists=1

directory=0

regFile=1

size=1

read=1

write=0

execute=0

input: $ 06-permissions ~turk/NetworkingClass/scripts/a0-whoIsOnTheSystem

output: thePath=[/home/turk/NetworkingClass/scripts/a0-whoIsOnTheSystem]

exists=1

directory=0

regFile=1

size=1

read=1

write=0

execute=1

input: $ 06-permissions ~turk/NetworkingClass/doesNotExist # exits with error code of 2

output: thePath=[/home/turk/NetworkingClass/doesNotExist]

That path does not exist.

input: $ 06-permissions /home/turk/NetworkingClass/empty

output :thePath=[/home/turk/NetworkingClass/empty]

exists=1

directory=0

regFile=1

size=0

read=0

write=0

execute=0

input: $ 06-permissions # exits with error code of 1

output: USAGE: 06-permissions Where is the name of the file or directory the script should access.

Ex: 06-permissions ~turk/NetworkingClass/sampleNames

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 Databases Questions!