Write a script that counts how many times a user tries to quit the program with an interrupt (typically Control-C), showing the count and finally letting them quit on the fifth attempt. Tip: You'll need to use trap for this and the interrupt signal is SIGINT
What will be an ideal response?
count=0
trap 'interrupt' 2
interrupt()
{
echo "I won't quit. Count = $count"
count=$(( ${count} + 1 ))
if [ $count -eq 5 ] ; then
echo "Enough! I'll quit, I'll quit."
exit 1
fi
}
echo "Use Control-C to try and quit this script."
sleep 9999
You might also like to view...
Which diagram is also called a collaboration diagram?
a. State machine diagram. b. Communication diagram. c. Activity diagram. d. Sequence diagram.
Information is passed to a method in ________.
a. the method name b. that method’s return c. the method body d. the arguments to the method
To display a format of 12/30/2018 in a date field regardless of how the data was entered, use the ________ format
A) Long Date B) Date/Time C) End Date D) Short Date
The ________ keyword is used in an assignment statement to create an object and place it in an object variable
Fill in the blank(s) with correct word