Next: About this document
Using the vi editor, write a Unix shell script (NOT a C program) on the Sun
cluster that
obeys the following specifications. Shell scripts are described on pages
283 - 293 of the text. Your shell script should:
- display the contents of the current working directory on the screen,
one page at a time
- display a menu giving the user the choice of displaying the contents
of a file; counting the characters, words and lines in a file; changing
directories; or exiting.
- prompt the user for menu selection. This can be done by numbering the
menu selections and having the user enter a number, or by having the user
enter a letter or keyword selection.
- handle each selection as follows:
- if the user selects displaying the contents of a file, prompt the
user for a filename. If the file exists, display its contents one page
at a time. If the file does not exist, print an error message.
- if the user selects counting the characters, words and lines in a
file, prompt the user for a file name. If the file exists, find and
display the number of characters, words and lines in the file. If the
file does not exist, print an error message.
- if the user selects changing directories, prompt the user for a
directory or path to change to. Your script should try to change to
the indicated directory, but does not need to check whether or not this
attempt is successful. In other words, if the directory or path entered
is valid, your script should change to that directory, but your script
need not handle the case where the directory or path isn't valid.
Your script should then display the contents of the current working
directory, one page at a time.
- if the user chooses to exit, your script should print a goodbye
message and terminate.
The script should run until the user selects
the option to exit. For any other selection, after the selected option
has been done, the menu should be redisplayed and the user should be able
to select another option.
(This is a variation on problem 10, p. 299 of the text.)
To hand in:
- Either turn in a print out of your script, or email me
(wahls@psu.edu) the file containing your script.
If you email me your script, I will email you your score and any comments
on your script sometime after the due date. I will also save a copy of
your script to prevent later disputes.
- Your script will be graded on correctness, style,
readability and the clarity
of messages printed for the user.
Next: About this document
Tim Wahls
Wed Mar 19 12:46:13 EST 1997