松哥的笔记
使用python的telnetlib进行设备访问
2024-10-11 lqy
import telnetlib
import time
def tel_connect(file_name=None,host=None,port=23):
tn=telnetlib.Telnet(host,port)
tn.read_until(b"Password:")
f=open(file_name)
lines=f.readlines()
for line in lines:
tn.write((line+"\n").encode("utf-8"))
time.sleep(1)
print(tn.read_very_eager().decode("utf-8"))
tn.close()
tel_connect("telnet.txt","10.98.249.12")
发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容