Found out a way to accomplish this. I created a loop within a loop. But it seems that i'm encountering problems as i go along.
Here's the update working script.
Code:
#!/bin/bash
clear
echo "Date Started `date`"
echo ""
echo " Enter IP or Hostname "
echo ""
read IP
echo ""
ssh noc@10.10.82.55 /usr/sbin/ping -sn $IP 56 10
echo ""
echo "Date Finished `date`"
echo ""
echo " The End!"
while :
do
echo ""
echo " Login to Host?"
echo " 1. To Login to Node"
echo " 2. To go back to EMS Utility"
echo ""
echo -n "Enter your choice [1 or 2]"
echo ""
read userchoice
case $userchoice in
1) while :
do
echo ""
echo "1. Cisco Router"
echo "2. Linux/Solaris Box"
echo ""
echo -n "Enter your choice [1 or 2]"
read userinput
case $userinput in
1) telnet $IP
exit
read ;;
2) ssh noc@$IP
exit
read ;;
*) echo "INVALID CHOICE!"
exit
esac
done ;;
2) echo ""
echo "Going back to EMS Utility"
exit
read ;;
*) echo "Not a valid choice"
exit
esac
done
Since the script is based on loops, how can i exit the loop if the initial ping fails? With this script if the ping fails it continues to the first loop. Any advice / suggestions?
Thanks.