Question: This next script will be a little dangerous. It will intercept the interrupt and stop signals ( -c and -z) and echo a simple message.

This next script will be a little "dangerous". It will intercept the interrupt and stop signals (-c and -z) and echo a simple message. Name the script danger.sh.

#!/bin/sh # some comment trap "echo I am done" SIGINT SIGSTOP 20 24 echo "pid is $$" while : do sleep 5 done

In its current state the program cannot be stopped with the normal -c or even -z. Note the -z works a little differently than -c. Since the interrupts are now replaced with an echo you will need another way to stop the program. You will need another terminal to kill the program. When the program is run note the pid reported. In the other terminal issue the following command:

sudo kill nnnn

LR(14/16): (2 pts.) Where nnnn is pid of the script. Note the above user has sudo enabled (this is the default for the first user created on an Ubuntu system). After the kill command is executed the script should stop and terminal control regained. Document the script printing a message when pressing either of the trapped signals.

Functions

The next script is a simple script (func1.sh) with two functions: quit and e1. quit has no arguments, e1 expects one argument.

#!/bin/sh # some comment function quit() { echo Bye! exit } function e1 { echo $1 } e1 Dog e1 Cat quit echo here?

LR(15/16): (4 pts.) Does the last echo command run? Explain your answer.

LR(16/16): (4 pts.) Modify the script so function e1 uses two arguments in its processing. Make the use interesting. One possibility is to add two numbers.

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