Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

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

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Information Modeling And Relational Databases

Authors: Terry Halpin, Tony Morgan

2nd Edition

0123735688, 978-0123735683

Students also viewed these Databases questions