python telnet登陆RouterOS执行相关命令,并返回命令执行结果,pythonrouteros,[Python]代码#T
python telnet登陆RouterOS执行相关命令,并返回命令执行结果,pythonrouteros,[Python]代码#T
[Python]代码
#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()
相关内容
- 利用bs4获取58同城城市分类,bs4获取58同城,python beaut
- Python 处理图像几何变换,python图像几何变换,[Python]代码
- python urllib2和httplib请求的速度比较实例测试,urllib2ht
- 使用python下载网页上的flash,pythonflash,[Python]代码''
- Python 批量获取《oschina》高亮代码区域源码!,python《
- Find bridges of graph,bridgesgraph,[Python]代码#
- 用Python实现一个简单的算术游戏,python实现算术,#!/us
- 绑定修改网卡绑定关系脚本,修改网卡绑定脚本,[Pyth
- 判断图片分辨率并修改,判断图片分辨率,[Python]代码
- 调节图片亮度和饱和度,图片亮度饱和度,[Python]代码
评论关闭