Experiment with the exec command by writing a series of three shell scripts called “a.sh,” “b.sh,” and “c.sh” that each display their name, execute ps, and then exec the next script in the sequence. Observe what happens when you start the first script by executing exec a.sh.

What will be an ideal response?


A shell can print out $0 to show the name of the command that was used to start it. Output from
the ps command will show it running. After executing the next script with exec, the student should
notice in the next ps output that the new script name is present but the old one is gone. This is
because exec replaces the current program with the new program when it runs it. At each
execution of a new script, the old one is replaced and only the new one will show up as currently
running. If you execute your first script with exec from your shell, then your shell itself is replaced
when the first script runs. Then when the last script in the chain terminates, you may find yourself
logged out of the system (or if you’re running in a terminal window, the terminal window will
exit)!

Computer Science & Information Technology

You might also like to view...

To record the starting address of each of its files, a portion of the disk’s first track is set aside to hold a(n) __________.

a. directory b. index c. boot record d. table

Computer Science & Information Technology

Which of the following are incorrect?

a. An abstract class contains constructors. b. The constructors in an abstract class should be protected. c. The constructors in an abstract class are private. d. You may declare a final abstract class. e. An interface may contain constructors.

Computer Science & Information Technology

Which of the following commands can be used to schedule very frequent recurring tasks, such as running once every minute?

A. run B. watch C. do D. while

Computer Science & Information Technology

?The ____ of a website typically includes copyright information.

A. ?header B. ?footer C. ?body D. ?navigation element

Computer Science & Information Technology