4.12 Menu shell script
- Use a text editor to create a
menu shell script. The shell script should have 8 options, as
listed. Do this twice, once using the Bourne shell
sh
or
the bash
shell,
and once
using the "C" shell csh
or the tcsh
shell.
If you wish you may do one of the scripts in the korn shell, ksh
.
- (
l
) Do a ls
for the current directory with the options
last specified with loption.
- (
loption
) Set the options for the above ls command.
- (
cmd
) Run the shell script cmd
from a previous lab.
See Lab 4.5: Lab Editor 2 -- pico (or vi).
- (
month
) Show the current month's calendar.
Use the cal
command without any arguments for this part.
- (
compile
) Compile a "C" program. Do a second keyboard
read to get the name of the file to compile. Save this name for
future compiles so if your script receives a null input it can compile
the "current" file. You may want to consider handling
file names both with and without the ".c
" ending.
- (
run
) Run a.out
the last "C" program compiled.
- (
exit
) Exit the script.
- If any other input is received it should be
passed to the shell as given.
- After processing one input line request a new input.
Use the "simple commands" case and read.
- Test all of the options for your shell script.
- Can you run your script within your script? Write a yes
or a no on the printout you turn in for each shell.
Make a printout of your menu program's output. To do this use the tee
command.
menuscript | tee file-to-print-name
tee
makes a copy of the standard input to a file and also sends the
standard input to the standard output.
Print out your run results and a copy of your
shell script, then mark the "C" or tcsh
shell version with:
your name
TABER CIS137
Lab 4.12: C or tcsh Shell Menu Program
and the Bourne or bash
shell version with:
your name
TABER CIS137
Lab 4.12: Bourne or Bash Shell Menu Program
Remember to answer the question about if you could run your shell script
within your shell script.
Place the lab in the instructor hand-in box
in BUS R6E, the "terminal room".
Instructor: ltaber@pima.edu ** My new Home at GeoApps in Tucson ** The Pima College Site ** The Mad Dr. G.'s home page on phred.