How to come out from telnet

Hi All,

I want check current whether client servers is able to connect to about 10 servers on a particular port .

When i am trying with telnet its hunging up after checking...Can pls suggest how to come out telnet after checking.

# telnet 129.39.13.38 9494
Trying...
Connected to 129.39.13.38.
Escape character is '^]'.

its hunging up here......

I want chekk it with for loop for the 10 servers..

regards,
ram:):slight_smile:

isn't '^]' working?

hi Soulman,
My actual script is as below

for i in `cat servers_list`
do
if telnet $i 9494 > /dev/null 2>&1 ; then
echo " able to connect to $i "
fi
done

in the above script I have 10 servers in server_list file and the script is not giving any output just hunging up ...Can u pls help me out

just try the escape sequence... i don't know how to implement this in your script but for 10 servers this might not be to hard to press ^] a maximum of 10 times...

You don't state o/s or shell but this should work:

#!/bin/ksh
cat servers_list | while read SERVER
do
        WAYOUT=`echo "\0035"`    # ctrl/]
        echo "${WAYOUT}\c" | telnet "${SERVER}" 9494 1>/dev/null 2>/dev/null
        ERROR=$?
        if [ ${ERROR} -eq 0 ]
        then
                echo "Able to connect to: ${SERVER}"
        else
                echo "Cannot connect to: ${SERVER}"
        fi
done

or use netcat for the tcp connection!

nc -vz www.google.com 80
DNS fwd/rev mismatch: www.google.com != www.l.google.com
www.google.com [74.125.39.103] 80 (www) open