Python: How to check telnet status?

Dmitry Romanoff - Nov 9 '23 - - Dev Community

Here is Python code that checks telnet status.

import sys
import telnetlib

#host=sys.argv[1]
#portno=sys.argv[2]

host=input("enter hostname:")
portno=input("enter host number:")

try:
    conn = telnetlib.Telnet(host,portno)
    response = host+' ' + portno +' - Healthy'
except:
    response = host+' ' + portno +' - Unhealthy'
finally:
    print(response)
Enter fullscreen mode Exit fullscreen mode
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player