python-3.xtelnetlib

How to check telnet client is installed or not on Remote windows machine


we have to test on 100 servers whether telnet is installed or not? if installed we have to check port is working or not (telnet 10.20.30.40 1234) if not installed we have to install and test the port is enabled or not? is it possible in Python script, if yes please help.

Thanks in advance.


Solution

  • Try this:

    import socket
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    result = sock.connect_ex(('0.20.30.40',1234))
    if result == 0:
       print "Port is open"
    else:
       print "Port is not open"
    sock.close()