Question: Tnis exercise uses the copy or tne script you savea after completing Lab Exercise 2 A . We will be modifying it in a way

Tnis exercise uses the copy or tne script you savea after completing Lab Exercise 2A. We will be modifying it in a way similar to the rest of Lab Exercise 2.
A. At the beginning of the script, add a line that defines a variable called TMP, and give it the initial value "/tmp/processID().txt". Then add another line that creates the file named by the value of TMP. Call this script "
scan3a.py". What is the actual name of the file created?
. In the for loop, before you print the file attributes, check to see if the file being examined is the file named by the value of TMP, and if so, immediately go to the next file (that is, do not get the file attributes). Call this script "
scan3b.py".
c. Modify your script so that the attributes are stored in the file named by the value of the variable TMP. Call this script "
scan3c.py".
D. After the loop, print the message "Changed files:", and then compare the contents of the files named by TMP and MASTER. Use diff to generate the comparison. Call this script "
scan3d.py". What happens if the file named by the value of MASTER does not exist?
E. Before the loop, check that the master file (the file named by the value of MASTER) exists. If it does not, print an error message saying "Master file does not exist; please generate it" and exit with an exit status code of 1. Call this script "
scan3e.py".
F. Conclude by using the command rm to delete the file named by the value of TMP after the comparison in Part D. Again, have the script exit with an exit status code of 0. Call this script "
scan3f.py".
When you test this script, the MasterList file must already exist. If it does not, execute the script you wrote in Lab Exercise 2.
You should get at least one line for the file MasterList. You will also get other lines corresponding to the scripts you wrote. As long as you get the line for MasterList, you're doing it right.
Also, from the command interpreter, check the exit code. Immediately after you execute your script, type
echo $?
This prints the exit status code of the command that finished most recently. That command is your script. So, you should see 0.
Tnis exercise uses the copy or tne script you

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!