2014/01/05

import telnetlib

f = open("switch")
lines = f.read().splitlines()
#print lines
command_arr = ["123456","en","123456","terminal length 0","sh mac add","exit"]
#print command_arr

for HOST in lines:
#print HOST
tn = telnetlib.Telnet(HOST)
for command in command_arr :
        tn.write(command + "\n")
#print tn.read_all()
content = tn.read_all()
print content
chk = content.find("1122.3344.5566") #找出這個mac是否在這台switch上 在那一個port上
print chk
tn.close()

沒有留言: