When you type your password, UNIX turns off echoing so what you type
won't show on the screen.
You can do the same thing in shell scripts with
stty -echo
.
stty
read
|
#!/bin/sh
...
trap 'stty echo; exit' 0 1 2 3 15
# use the right echo for your UNIX:
echo "Enter code name: \c"
#echo -n "Enter code name: "
stty -echo
read ans
stty echo
...
|
The response is stored in
$ans
.
The
trap
(
44.12
)
helps to make sure that, if the user presses
CTRL-c
to abort the script, characters will be echoed again.