Contents
- INDEX
- Unix Scripts Index
- HP-UX
- Solaris
- Linux Index
- General Unix
- Unix Networking
- Other Unix types
- Unix databases
Associated Information
- none
|
Reading responses from the terminal
This script only excepts a response of y, Y, n or N and will loop round
until it gets the correct response.
#!/usr/bin/ksh
###### if yesorno ; then
###### execute this command i.e. the answer was yes
###### else
###### execute this instead i.e. the answer was no
until [ "$Answer" = "y" ] || [ "$Answer" = "Y" ] ||
[ "$Answer" = "n" ] || [ "$Answer" = "N" ] ; do
echo "Answer with (y/n)!\c"
read Answer
done
case $Answer in
y|Y)
echo "Your answer was yes"
;;
n|N)
exit 0200
;;
esac
|