Submenu not working as expected
by JugaruGabi from LinuxQuestions.org on (#501QN)
So I am having the following scenario:
Main Menu Option
|
-- Submenu 1
|
-- Submenu 2
In submenu 2 I have the following code:
Code: echo "IMPORTANT: By using his option, you will start a custom batch of servers which will be defined below."
echo "Make sure that the custom batch is typed in an ascending order, otherwise you will not have the desired result and unwanted servers might be started!"
echo ""
read -p "Start from (e.g. 1): " ais_start_custom_from_prd
read -p "Start to (e.g. 4): " ais_start_custom_to_prd
echo ""
local PS3='What instances should be started: '
local options=("1" "2" "MAINT" "Both present on sever" "Cancel")
select opt in "${options[@]}"
do
case $REPLY in
1)
until [ $ais_start_custom_from_prd -gt $ais_start_custom_to_prd ]
do
prod_ais_start=$(echo "host$ais_start_custom_from_prd")
echo $prod_ais_start
for host in "$prod_ais_start"; do
ssh -qo StrictHostKeyChecking=no $host << EOF
echo ""
hostname
. ~/.profile
echo "1"
path/to/start/scripts
EOF
((ais_start_custom_from_prd=ais_start_custom_from_prd+1))
done
read -rsn1 -p "Press any key to continue... "
break
;;
2)
until [ $ais_start_custom_from_prd -gt $ais_start_custom_to_prd ]
do
prod_ais_start=$(echo "host$ais_start_custom_from_prd")
echo $prod_ais_start
((ais_start_custom_from_prd=ais_start_custom_from_prd+1))
done
break
;;
3)
until [ $ais_start_custom_from_prd -gt $ais_start_custom_to_prd ]
do
prod_ais_start=$(echo "host$ais_start_custom_from_prd")
echo $prod_ais_start
((ais_start_custom_from_prd=ais_start_custom_from_prd+1))
done
break
;;
4)
until [ $ais_start_custom_from_prd -gt $ais_start_custom_to_prd ]
do
prod_ais_start=$(echo "host$ais_start_custom_from_prd")
echo $prod_ais_start
((ais_start_custom_from_prd=ais_start_custom_from_prd+1))
done
break
;;
5)
break
;;
*) echo "Option $REPLY is not valid";;
esac
done
break ;;which fails with the following error:
Code:./bash.sh: line 373: syntax error near unexpected token `;;'
./bash.sh: line 373: ` ;;'If I copy and paste the commands from point 4 to point 1 it works without any kind of issues.
I cannot seem to understand where the issue lies that results in this error when attempting to start the bash with the start command to the server but not have the same error when having only the echo of the servers hostname...
Can you guys help me to understand where is the problem here?
Thanks in advance.


Main Menu Option
|
-- Submenu 1
|
-- Submenu 2
In submenu 2 I have the following code:
Code: echo "IMPORTANT: By using his option, you will start a custom batch of servers which will be defined below."
echo "Make sure that the custom batch is typed in an ascending order, otherwise you will not have the desired result and unwanted servers might be started!"
echo ""
read -p "Start from (e.g. 1): " ais_start_custom_from_prd
read -p "Start to (e.g. 4): " ais_start_custom_to_prd
echo ""
local PS3='What instances should be started: '
local options=("1" "2" "MAINT" "Both present on sever" "Cancel")
select opt in "${options[@]}"
do
case $REPLY in
1)
until [ $ais_start_custom_from_prd -gt $ais_start_custom_to_prd ]
do
prod_ais_start=$(echo "host$ais_start_custom_from_prd")
echo $prod_ais_start
for host in "$prod_ais_start"; do
ssh -qo StrictHostKeyChecking=no $host << EOF
echo ""
hostname
. ~/.profile
echo "1"
path/to/start/scripts
EOF
((ais_start_custom_from_prd=ais_start_custom_from_prd+1))
done
read -rsn1 -p "Press any key to continue... "
break
;;
2)
until [ $ais_start_custom_from_prd -gt $ais_start_custom_to_prd ]
do
prod_ais_start=$(echo "host$ais_start_custom_from_prd")
echo $prod_ais_start
((ais_start_custom_from_prd=ais_start_custom_from_prd+1))
done
break
;;
3)
until [ $ais_start_custom_from_prd -gt $ais_start_custom_to_prd ]
do
prod_ais_start=$(echo "host$ais_start_custom_from_prd")
echo $prod_ais_start
((ais_start_custom_from_prd=ais_start_custom_from_prd+1))
done
break
;;
4)
until [ $ais_start_custom_from_prd -gt $ais_start_custom_to_prd ]
do
prod_ais_start=$(echo "host$ais_start_custom_from_prd")
echo $prod_ais_start
((ais_start_custom_from_prd=ais_start_custom_from_prd+1))
done
break
;;
5)
break
;;
*) echo "Option $REPLY is not valid";;
esac
done
break ;;which fails with the following error:
Code:./bash.sh: line 373: syntax error near unexpected token `;;'
./bash.sh: line 373: ` ;;'If I copy and paste the commands from point 4 to point 1 it works without any kind of issues.
I cannot seem to understand where the issue lies that results in this error when attempting to start the bash with the start command to the server but not have the same error when having only the echo of the servers hostname...
Can you guys help me to understand where is the problem here?
Thanks in advance.