python telnet登陆RouterOS执行相关命令,并返回命令执行结果,pythonrouteros,#Telnet Rout
文章由Byrx.net分享于2019-03-23 09:03:30
python telnet登陆RouterOS执行相关命令,并返回命令执行结果,pythonrouteros,#Telnet Rout
#Telnet RouterOs & Run Command v0.1#python v3.2#Routeros v3.27import telnetlib,time,os#config_user_password_port_etc.HOST='192.168.1.1'PORT='23'user= 'test'password= '1'command_1='ping 8.8.8.8 c 10'command_2='quit'tn=telnetlib.Telnet(HOST,PORT)tn = telnetlib.Telnet(HOST)#input usertn.read_until(b"Login: ")tn.write(user.encode('UTF-8') + b"\\n")#input passwordtn.read_until(b"Password: ")tn.write(password.encode('UTF-8') + b"\\n")#run commandtn.read_until(b'>')tn.write(command_1.encode('UTF-8')+b"\\r\\n")time.sleep(10)tn.read_until(b'>')tn.write(command_2.encode('UTF-8')+b"\\r\\n")#write result in files#print(tn.read_all)result=tn.read_all()file_object=open('result.txt','wb')file_object.write(result)file_object.close()print ('Finish')tn.close()#该片段来自于http://byrx.net
相关内容
- 遍历目录下所有文件,遍历目录文件,通过os.path.wa
- 绑定修改网卡绑定关系脚本,修改网卡绑定脚本,pytho
- 调节图片亮度和饱和度,图片亮度饱和度,通过用户输入
- python数组插入新元素,python数组新元素,li=['a', 'b'
- 包含HTTP Forward的小HTTP Server,forwardserver,以前自己调试
- urllib的简单运用--访问网站,urllib运用--,urllib的简单运
- 删除SVN目录和.o文件,svn目录.o,title = 'thi
- 输出100以内的素数,输出100素数,for i in ran
- 坑爹的 Sleep Sort,坑爹sleepsort,睡眠排序法:待排序队列
- 用Python实现二分查找,Python实现二分查找,#!/usr/bin/e
评论关闭