标签:open fqdn bin python sed 客户端 sock exce main
MAC 下运行的 telnet 客户端,需要安装 python3 的环境。if name == ‘main‘:
if len(sys.argv) != 3:
print("Usage: telnet [remote_ip | FQDN] [remote_port]")
exit()
if re.match(r"\d{1,5}",sys.argv[2]) is None:
print("remote port must be number")
exit()
hostname = sys.argv[1]
remote_port = int(sys.argv[2])
telnet_client = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
try:
telnet_client.connect((hostname,remote_port))
print(hostname+":"+str(remote_port)+" is open\n")
exit()
except Exception:
print(hostname+":"+str(remote_port)+" is closed\n")
exit()`
标签:open fqdn bin python sed 客户端 sock exce main
原文地址:https://blog.51cto.com/qinlouke/2529576