- 论坛徽章:
- 0
|
#_*_coding:utf-8_*_
#
'''
多线程ping
'''
import datetime
import os,time
from threading import Thread
f = file("output.txt","w+")
p = ["采集器通断结果:"]
f.writelines(p)
f.close()
start = time.clock()
path = 'ip.txt'
lie = []
result = []
class testip(Thread):
def __init__(self,ip):
Thread.__init__(self)
for ip in open(path):
ip = ip.replace('\n','').split("-")
ip = ip[0]
print ip
p = os.popen("cmd.exe/k ping -n 3 %s " % ip).read()
#print p
ms = "TTL=127"
if ms not in p :
f = file("output.txt","a+")
f.write(p)
f.close()
#print p
end = time.clock()
shi = end - start
print shi
print "ok"
这个是我写的,不知道怎么用多线程 |
|