back_switch.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:wechat_oms 作者: bsbforever 项目源码 文件源码
def switch(hostname,username,password1,password2,cmd1,cmd2):
    tn = telnetlib.Telnet(hostname,timeout=10)
    #tn.set_debuglevel(2)
    tn.read_until("Username: ")
    tn.write(username + "\n")
    tn.read_until("Password: ")
    tn.write(password1 + "\n")
    tn.read_until(">")
    tn.write('en'+ "\n")
    tn.read_until("Password: ")
    tn.write(password2 + "\n")
    tn.read_until("#")
    tn.write("terminal length 0"+"\n")
    tn.write(cmd1 + "\n")
    tn.write(cmd2 + "\n")
    #tn.read_until("#")
    tn.write("exit\n")
    result=tn.read_all()
    #print tn.read_all()
    return result
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号