1 Star 0 Fork 45

yangjian33o/qytang_Python

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
2016.1.29 Rack-AUTO-Clearline 909 Bytes
一键复制 编辑 原始数据 按行查看 历史
现任明教教主-乾颐堂 提交于 2016-01-29 21:06 . new file
#!/usr/bin/python3
from telnetlib import Telnet
def routerclearline(username, password, rackno, routerno = 20):
if rackno == 'BJRack01':
rackip = '172.17.100.111'
elif rackno == 'BJRack02':
rackip = '172.17.100.112'
elif rackno == 'BJRack3':
rackip = '172.17.100.113'
tn = Telnet(rackip)
sendusername = username.encode()
tn.read_until(b'Username: ')
tn.write(sendusername + b'\n')
sendpassword = password.encode()
tn.read_until(b'Password: ')
tn.write(sendpassword + b'\n')
tn.read_until(b'QYT-Rack')
if routerno == 20:
for i in range(20):
command = 'clear line ' + str(i) +'\n\n'
tn.write(command.encode())
else:
command = 'clear line ' + str(routerno) +'\n\n'
tn.write(command.encode())
tn.write(b'exit\n')
print(tn.read_all().decode('ascii'))
if __name__ == "__main__":
routerclearline('labtest', 'xxxxx', 'BJRack01', 1)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/yangjian33o/qytang_Python.git
git@gitee.com:yangjian33o/qytang_Python.git
yangjian33o
qytang_Python
qytang_Python
master

搜索帮助