问题描述
我在gns3实验室中将telnet的确切python脚本写到了Cisco路由器和交换机中,它正在工作,但是至少需要10到20分钟才能在终端上显示结果,我的操作系统是Ubuntu 20.04,对于某些我既不想使用gns3自动化容器也不想使用python2的原因。(配置了TAP设备,我可以轻松ping和telnet到我的设备,因此手动配置没有问题),这里是脚本:
#!/usr/bin/env python3
import getpass
import telnetlib
HOST = "10.10.10.1"
user = input("Enter your username: ")
password = getpass.getpass()
tn = telnetlib.Telnet(HOST)tn.read_until(b"Username: ")
tn.write(user.encode('ascii') + b"\n")
if password:
tn.read_until(b"Password: ")
tn.write(password.encode('ascii') + b"\n")
tn.write(b"enable\n")
tn.write(b"conf t\n")
dev_info = tn.read_all().decode('ascii')
tn.close()
print(dev_info)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)