首页 > 代码库 > 【工作常用代码集】批量Telnet远端端口

【工作常用代码集】批量Telnet远端端口

作者:gnuhpc
出处:http://www.cnblogs.com/gnuhpc/

__author__ = gnuhpcimport telnetlib,socketIP={}def parseTel(line):    parseArray = line.split()    IP[parseArray[0]]=parseArray[1]with open("tel.lst") as f:    for line in f:        parseTel(line)for (ip,port) in  IP.items():    try:        tn = telnetlib.Telnet(ip,port,1)        tn.close()    except socket.error, why:        print ip,port,why