This code will run only for the first match because of the lines under functions: service httpd start but it will display echo from all functions if I remove all ssh... lines. Could someone explain it to me what is happening and maybe some solution how I can use it.
#!/bin/bash
function s1 {
echo "running 1 "
ssh user@server_1_IP service httpd start
}
function s2 {
echo "running 2"
ssh user@server_2_IP service httpd start
}
function s3 {
echo "running 3"
ssh user@server_3_IP service httpd start
}
whiptail --title "Test" --checklist --separate-output "Choose:" 20 78 15 \
"Server1" "" on \
"Server2" "" on \
"Server3" "" on 2>results
while read choice
do
case $choice in
Server1) s1
;;
Server2) s2
;;
Server3) s3
;;
*)
;;
esac
done < results