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

See also Usage examples in scripts

Recent Changes

Contribute to this wiki

Why not help others by sharing your knowledge? Contribute something to this wiki and join out hall of fame!
Contact us for a user name and password