I have some commands to prompt for yes or no answer in my script, but the read answer command (interactive mode) not working, while running the script using ssh bash -s script.
ssh user@hostname bash -s < "/home/xxxx/devstop.sh"
it is not prompting the question from remote shell and exits to the source shell.
My script :
if [ "$count" -eq "0" ]
then
echo -e "${GREEN}Tomcat Server stopped successfully on '$HOSTNAME' ${NC}"
elif [ $count -gt "0" ]
then
echo -e "${RED}Tomcat Server not stopped on '$HOSTNAME' please check it ${NC}"
echo "Do you want to continue all the tomcat server shutdown process in -`date` "
echo " Please Read the Above and Enter (Y/N) to Proceed or Stop to cancel shutdown processes : \c"
read answer
value=`echo ${answer} | tr -s '[:lower:]' '[:upper:]'`
if [ "$value" = "Y" ]
then
echo " Remaining tomcat Services are going down."
else
echo " Cancelled tomcat Services shutdown process in '$HOSTNAME."
exit 1;
fi
fi
ps -ef|grep tomcat|grep -v grep |grep -i "catalina.startup.Bootstrap start"
exit