I'm currently new to scripting and would want to ask for your assistance/suggestions. I have created a script that would ping a certain IP Address or Hostname that is entered by the User. After the ping finishes the script would prompt the user if they want to login to the node.
Here's were my problem comes in. The IP Address or Hostname could be a Cisco Router or a Linux/Solaris box. I want the script to try and Telnet to the IP or Host and it fails try to ssh on it. I'm guessing that the script would base it decision on the error messages it receives when trying to perform a telnet or ssh. I don't know how to do this and any assistance would be greatly appreciated.
-bash-3.00$ ssh 10.10.30.11ssh: connect to host 10.10.30.11 port 22: Connection refused
-bash-3.00$ telnet 10.10.80.184
Trying 10.10.80.184...telnet: Unable to connect to remote host: Connection refused
Here is script.
echo "Date Started `date`"
echo Enter IP
ssh [email protected]
ping -sn $IP 56 10
echo "Date Finished `date`"
echo " The End! "
echo "Login to Host?"
echo "1. To Login to Node"
echo "2. To go back to Menu"
echo -n "Enter your choice [1 or 2]"
case $userchoice in
1) telnet $IP
2) echo "Going back to Menu"
*) echo "Not a valid choice"
Thanks in advance.[code][/code]