#!/bin/env  python
import telnetlib,time,sys
iplist=[]
f=open('ip.txt','r')
for i in f:
iplist.append(i)
def conn(x,y):
T=telnetlib.Telnet
user=''  ##用户名
pw=''    ###密码
enpw=''  ###全局密码
tl=T(x)
tl.read_until('Username:')
tl.write(user+'\n')
tl.read_until('Password:')
tl.write(pw+'\n')
tl.write('en\n')
tl.read_until('Password:')
tl.write(enpw+'\n')
tl.write(y+"\n   ")
time.sleep(3)
print tl.read_very_eager()
cmd=['sh ver','sh cdp nei']
for ip in iplist:
print i
for m in cmd:
print m
conn(ip,m)