Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4. Write a script called addexec.sh that will take a single filename as an argument and adds execute permission to the file for the user.

image text in transcribed

4. Write a script called addexec.sh that will take a single filename as an argument and adds execute permission to the file for the user. Below are a few more details about your script. a. The script should only work for regular file. b. The script must check to see that there is exactly one argument. If there are no arguments or more than one argument, the script must produce a "usage" message that tells how to use the script. You write it this way: echo "Usage: $0 filename" C. The script must check that the file exists; if it doesn't, it should give an error message. d. The script must check that the file is a regular file, otherwise it should give an error. e. The script must add execute permission for all users (i.e., the owner, group and others), and leave all other permissions exactly as they were. Before running the script, create an empty file called textfile1, and an empty directory called folder1. Use the newly created file and directory to test your script. Below is the sample result after running the script several times: $ ./addexec.sh Usage: ./addexec.sh filename $ ./addexec.sh textfile1 textfile2 Usage: ./addexec.sh filename $ ./addexec.sh folder1 folder1 is not a regular file. $ ./addexec.sh nonexistingfile nonexistingfile does not exist. $ ./addexec.sh textfile Successfully added execute permission to textfile $ ls -l textfile -rwxr-xr-x 1 student01 users 0 2020-10-06 17:38 textfile

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

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

Recommended Textbook for

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

More Books

Students also viewed these Databases questions