I’m trying to write a professional program to accept and process input via a Menu based system. The program should have no command line arguments. it will be writen in csh script called TaskMenu. This shell script will:
- ask for a password from the user.
a. If the password is not correct, the system will exit
with an appropriate error message. - display a text menu and then get a response from the user.
- process the user input and redisplay the text menu
until the user wants to quit.
To read a password, turn echo off, read the password, then re-enable echo. csh:
To create a menu, just echo the choices to the screen, then
read a value back. csh:
These same two tasks in bash are:
Read password:
Make menu:
Notice how reading a password and making a menu are built-in to bash. In addition to being easier, some common things done in scripting are impossible in csh. Csh is not designed as a scripting language. It is much easier to use Bash, Python, Ruby, Perl or even the lowly /bin/sh for scripting anything over a few lines.
That said, here is a full csh script showing the password and menu methods:
Notes
1 Wikipedia