Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

telnet korn shell script

Status
Not open for further replies.

icu812

MIS
Sep 10, 2001
52
US
I have a box(sp node) that intermittently, I can't telnet to
I can ping it but I cannot telnet to it. Can someone please help me come up with a korn shell script that will try to telnet to this box and send me an e-mail message if it can't? As always: Thank you very much
 
The AIX version of telnet does not exit with result codes. You'll need to do something like this:

#!/bin/ksh
host=sap80i
telnet $host 1>/tmp/file 2>&1
foo=`grep refused /tmp/file`
if [ "$?" -eq "0" ] ; then
echo "Host $host does not respond"
fi

Bill.
 
I've tried this script but am having problems:
1) whenever I am having problems with the server, I get "Trying..." when I try to telnet to it.

2) that same string (Trying...) is part of a successful telnet connection

3) Do you know how I can search for this string when I am having problems, if it is also showing up when I am not having problems...Am I confusing you??)

4) Also, the script hangs

Thanks for your help! I really appreciate it.
 
Let it run for a short while. It should time out. There is nothing else you can do, unless you rely on "ping" to test connections.

Bill.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top