Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ksh while statement fails 1

Status
Not open for further replies.

revilord

Programmer
Oct 2, 2003
64
The following shile statement fails and I have tried several variations but can seem to get it to work. I'm not a ksh expert and I am trying to fix a program that is migrating from csh. Thanks for any help.

#!/bin/ksh
echo "Start. . ."
read CHOICE
while [[ "$CHOICE"!="q" && "$CHOICE"!="Q" ]]
do
if [ "$CHOICE" == "" ]; then
echo "Choice is blank"
else
echo "Choice is $CHOICE"
echo ""
echo -n 'Press <RETURN> to Continue . . .'
read test
break
fi
break;
done
 
Replace this:
while [[ "$CHOICE"!="q" && "$CHOICE"!="Q" ]]
By this:
while [ "$CHOICE" != "q" -a "$CHOICE" != "Q" ]
And this:
if [ "$CHOICE" == "" ]; then
By this:
if [ -z "$CHOICE" ]; then

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top