Last active
October 4, 2017 08:32
-
-
Save lrivallain/94db5ec9bdc76a0938a388d26a47dcd4 to your computer and use it in GitHub Desktop.
A telnet replacement in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import socket | |
import sys | |
if len(sys.argv) != 3: | |
print("usage: telnet.py IPADDRESS PORT") | |
exit(-1) | |
print("Opening connection on %s port %s" % (sys.argv[1], sys.argv[2])) | |
try: | |
conn=socket.create_connection((sys.argv[1],sys.argv[2]),timeout=30) | |
except socket.timeout: | |
print("Connection error: timeout") | |
exit(-1) | |
except: | |
print("Connection error: unknown") | |
exit(-1) | |
print("Connection succeed") | |
exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment