
Originally Posted by
pablo0713
I have a script that works well in Unix. The syntax is as follows:
Code:
menu_1 () {
Command 1
Command 2
}
menu_2 () {
Command 1
Command 2
}
while :
do
cat << !
Please select:
1. Menu 1
2. Menu 2
3. Quit
!
echo "Your choice? : "
read choice
case $choice in
1) menu_1;;
2) menu_2;;
3) quit;;
*) echo "\"$choice\" is not valid "; sleep 2;;
esac
done
[/CODE]
However, when I try to the case command in the same way under Linux, I get a series of syntax errors that reference either the closing } or any line that starts off with "Menu." Removing the case command and menu options from the script and it works fine. Can anyone help me or point me to a good tutorial that uses case in Linux for building a menu?
That code works perfectly well in Linux. Are you sure you are using a Bourne-type shell (bash, dash, pdksh, ksh93).
Try putting a shebang line at the top of your file:
Post the exact error mesages you get if you continue to have problems.