Operating System - Linux
1754020 Members
7735 Online
108811 Solutions
New Discussion

Re: Checking if telnet works

 
SOLVED
Go to solution
Geoff Wild
Honored Contributor

Re: Checking if telnet works


Do something like:

echo ^C\n |telnet box2 |grep Connected

That will remove the interactive part...

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Kalim  Jacobs
New Member

Re: Checking if telnet works

I was able to write a perl script to do a similar task using Net::Telnet as suggested by ACS above.

Here's a command line just like GW's that makes more sense to me. (Probably just fooling myself)

# sh
# #working
# echo ^] | telnet hueco | grep Connected
Connected to hueco.rsn.hp.com.

# #bad hostname
# echo ^] | telnet nothing | grep Connected
nothing: Unknown host

# #machine not booted
# #takes a while to timeout!
# echo ^] | telnet svvp12 | grep Connected
telnet: Unable to connect to remote host: Connection timed out


The trick here is how to send the ctrl-]. Use this key sequence: ctrl-v ctrl-].
You can use ctrl-v and then any other ctrl sequence to get that exact sequence.

Note that cut-n-paste from this forum will NOT grab the ctrl-C or ctrl-]!!