Question: LAB EXERCISE 2 You are now going to modify the script you write for Lab Exercise 1 D to see if a master file exists

LAB EXERCISE 2
You are now going to modify the script you write for Lab Exercise 1D to see if a master file exists and, if it doesn't, create one. Then, in the loop, you will ignore any non-regular files and the master file.
A. At the beginning of the script, add a line that defines a variable called MASTER, and give it the initial value "MasterList". Call this script "
scan2a.py". When you are done, save a copy because you will use this in Lab Exercise 3.
. After the variable definition but before your loop, test to see if the file named by the value of the variable MASTER exists. If so, print the message that the file "exists; please delete it" and exit, giving exit status code 1. If not, create it. Call this script "
scan2b.py".
c. In the for loop, before you print the file attributes, check to see if the file being examined is either a regular file or the MasterList file. If it is neither, immediately go to the next file (that is, do not get the file attributes). Call this script "
scan2c.py".
d. Modify your script so that the attributes are stored in the file named by the value of the variable MASTER. Call this script "
scan2d.py".
E. Finally, if everything works, have the script exit with an exit status code of 0. Call this script "
scan2e.py".
Run your script. There should be no output. Then look for a file called MasterList and compare its contents to what you got for the output of
script1.sh. The outputs for the files abc xyz, abcde,
demo.for.sh,
demofor2.sh, and demofor3sh should be the same. The other files that are present should all be ones you created or put there.
LAB EXERCISE 2 You are now going to modify the

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