I have a select menu driven script using a case statment and cannot control what happens after a user's input is just <ENTER> or the <SPACEBAR>+<ENTER>. I want it to just hit the "MAIN" function and not redraw the options. I've look everywhere for the answer and am at a loss.
Here's the code:
-------------------------------------------------------------------
#!/usr/bin/ksh
MAIN ()
{
clear
echo " Main Menu"
echo "--------------------------"
PS3=$'--------------------------\n\nSelect Option: '
select option in "Refresh" "Exit" "Stop" "Start"
do
case ${option} in
'') echo "Invalid Choice";sleep 2;MAIN;;
"Exit") exit;;
"Refresh") MAIN;;
"Stop") echo STOP;exit;;
"Start") echo START;exit;;
esac
done
}
MAIN
--------------------------------------------------------------------
Here's what the screen looks like when executed:
Main Menu
--------------------------
1) Refresh
2) Exit
3) Stop
4) Start
--------------------------
Select Option:
When you press <ENTER> or the <SPACEBAR>+<ENTER> from this menu it shows this:
Main Menu
--------------------------
1) Refresh
2) Exit
3) Stop
4) Start
--------------------------
Select Option:
1) Refresh
2) Exit
3) Stop
4) Start
--------------------------
Select Option: [/COLOR]
I figured that the '') in the case statement would work but it is only handling any selection that is not valid. I figured that <ENTER> or the <SPACEBAR>+<ENTER> would be caught under this but it isn't.
If anyone know how to correct this your would be much appreciated.