import multiprocessing
import time,os,math
def func(msg):
output=os.popen("ssh %s hostname" %(msg)).read()
print output
if __name__ =="__main__":
flist=open('b').readlines()
pool =multiprocessing.Pool(processes=7)
for i in flist:
msg=i.replace('\n','')
pool.apply_async(func, (msg, ))
pool.close()
pool.join()
print"Sub-process(es) done."
import time,os,math
def func(msg):
output=os.popen("ssh %s hostname" %(msg)).read()
print output
if __name__ =="__main__":
flist=open('b').readlines()
pool =multiprocessing.Pool(processes=7)
for i in flist:
msg=i.replace('\n','')
pool.apply_async(func, (msg, ))
pool.close()
pool.join()
print"Sub-process(es) done."
b文件是个IP列表
一个IP一行即可