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

Computer Science & Information Technology

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.

Computer Science & Information Technology

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

Computer Science & Information Technology

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

Computer Science & Information Technology

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

Computer Science & Information Technology