hi anurag,
Thanks for the code actually I wanted to have a script in perl or shell as i dont knw python. It will be something like this if the server is up work on it else goto next one in list.
Thanks, King
--- Anurag anurag@hbcse.tifr.res.in wrote:
King wrote:
Hi guys ,
I want to write a script that will check the
ssh
connection can u suggest me best method to do that apart from ping (telnet ) on the ssh port or nmap
i
knw that but anything better than this ...
Why do you want to do so? telnet is a neat way for checking it. However if you must use some script then try this python script:
#!/usr/bin/env python """ File: sshtest.py Usage: $ python sshtest.py """
import socket,os server='gnu.hbcse' port=22 srv=socket.socket(socket.AF_INET,socket.SOCK_STREAM) try: srv.connect((server,port)) print('port '+str(port)+' @ '+server+' open') srv.close() except Exception: print('port '+str(port)+' @ '+server+' closed')
-Anurag
--
__ __
gnu /noo/ n. Ox like antelope; (abbr.) /gnoo/ (recursive acronym) Gnu's Not Unix.
__________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com