码迷,mamicode.com
首页 > 编程语言 > 详细

Learning Python telnet.lib

时间:2018-07-19 14:53:59      阅读:131      评论:0      收藏:0      [点我收藏+]

标签:mina   inpu   min   read   you   password   telnet   pytho   learning   

#!/usr/bin/env python import getpass import sys import telnetlib HOST = "X.X.X.X" user = raw_input("Enter your telnet username: ") password = getpass.getpass() tn = telnetlib.Telnet(HOST) tn.read_until("username: ") tn.write(user + "\n") if password: tn.read_until("password: ") tn.write(password + "\n") tn.write("terminal length 0\n") tn.write("sh run | sec hostname") tn.write("exit\n") output_*** = tn.read_all()

Learning Python telnet.lib

标签:mina   inpu   min   read   you   password   telnet   pytho   learning   

原文地址:http://blog.51cto.com/blade20/2147141

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!