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 (
#!/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
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
Get step-by-step solutions from verified subject matter experts
