Hi guys...was trying to use while loop and a sentry to prompt user input again if an invalid option was entered...but somehow I got a "while" unmatched error...The code is as below:
#!/system/bin/sh
finsh=0
while [ $finish -ne 0 ]
do
echo "Please select an option: "
echo "1. One" echo "2. Two"
echo "3. Three"
echo "4. Exit"
echo -n "Enter your selection: "; read opt
if [ $opt -eq 1 ]; then
echo "Please enter your next selection: "
echo "1. ABC"
echo "2. DEF"
echo "3. Main Menu"
subopt=0
while [ $subopt -lt 1 ] || [ $subopt -gt 3 ]
do
echo -n "Enter your selection: "; read subopt
if [ $subopt -eq 1 ]; then
echo "ABC"
echo "Hit enter to continue..."
read enterKey
elif [ $subopt -eq 2 ]; then
echo "EFG"
echo "Hit enter to continue..."
read enterKey
elif [ $subopt -eq 3 ]; then
echo "Returning to main menu"
echo "Hit enter to continue..."
read enterKey
else
echo "Invalid option, please try again..."
fi
done
elif [ $opt -eq 2 ]; then
echo "Two"
echo "Press enter to continue..."
read enterKey
elif [ $opt -eq 3 ]; then
echo "Three"
echo "Press enter to continue..."
read enterKey
elif [ $opt -eq 4 ]; then
echo "Bye!"
finish=1
else
echo "Invalid option, please try again"
fi
done
exit
Thanks in advance...