Link to home
Start Free TrialLog in
Avatar of subratoc
subratoc

asked on

Telnet connectivity query

Hi All,
I want to check telnet connectivity for a series of 50 IPs.
I tried to automate the tasks using a script like the following:
a=`echo pwd | telnet IP1`
a=`echo pwd | telnet IP2`
a=`echo pwd | telnet IP3`
...
...
a=`echo pwd | telnet IP50`

When I run the above script, it usually returns the chracaters "Connection closed by foreign host" for each IP.
Sometimes it returns different messages like "Connection refused", "No route to Host" etc.

But the problem occurs when the telnet fails altogether for a IP. If the telnet fails for a particular IP, the script waits for 3 minutes and returns the characters "telnet failed" and then the script is terminated.
Is there any way I can make the script return the character "telnet failed" within, say 3 seconds, for every IP it fails to connect to.
In other words, if I just run the command "telnet IP" on UNIX prompt and the telnet fails then I should get back "telnet failed" message within 3 seconds instead of 3 mins.
ASKER CERTIFIED SOLUTION
Avatar of lanboyo
lanboyo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lanboyo
lanboyo

expect is preferable, as it would allow you to check for good and bad passwords.
Avatar of subratoc

ASKER

Thanks, lanboyo. It worked perfectly!