Rewrite the journal script of Chapter 8 (exercise 5, page 3) by adding com- mands to verify that the user has write permission for a file named journal- file in the user’s home directory, if such a file exists. The script should take appropriate actions if journal-file exists and the user does not have write permission to the file. Verify that the modified script works.
What will be an ideal response?
$ cat journal2
# journal: add journal entries to the file
# $HOME/journal-file
file=$HOME/journal-file
# Check that $file is writable, exit if not
# (it is not writable if it does not exist)
if [ ! -w $file ]
then
echo "$file is not writable, it might not exist"
exit
fi
date >> $file
echo -n "Enter name of person or group: "
read name
echo "$name" >> $file
echo >> $file
cat >> $file
echo "--------------------------------------------------------"
>> $file
echo >> $file
You might also like to view...
In PHP, the ________ block always is executed after the try and catch blocks.
a. finally b. exception c. else d. throw
Freeware can be used at no cost for an unlimited period of time
Indicate whether the statement is true or false
Describe slope overload distortion.
What will be an ideal response?
In the hashing implementation of a dictionary, the data field of each node in a chain contains an Entry object.
Answer the following statement true (T) or false (F)