-   Programming (
-   -   another help with scripting?! (

ice99 08-08-2005 09:15 AM

another help with scripting?!
in my script i need to have only 2 answers, YES and NO. and if someone answer something else i heed to tell him that answers are only YES and NO and no others and to redirect him again to the same question.


echo -n "Do you want to make a new copy (yes/no)"
(if YES then continue) (if NO again continue) ( if something else "answer only with YES or NO Do you want to make a new copy (yes/no))???

satinet 08-08-2005 09:28 AM

This works for me - asking a question to confirm whether to proceed or not in a script....

echo "\n"
echo "LAST chance to back out"
echo "Are the detail correct?"
read Answer

while [ $Answer != 'n' ] && [ $Answer != 'y' ]
echo "Please press y or no and press enter"
read Answer

urka58 08-09-2005 09:56 AM

For the purpose <case> could be a good solution

echo -n "Do you want to make a new copy (yes/no)"
read i
case $i in
/usr/bin/cp /path/to/source /path/to/dest
echo "Possible answers are only yes or no"

this is for a simple task script.
If other actions follow, it could be useful using some functions
Hope this helps

All times are GMT -5. The time now is 10:19 PM.