展开全部
python脚本实现多次5261循环执行shell命令有三4102种方法,代1653码如下:#方法一
os.system
import os
i = 0
while True:
i = i + 1
os.system("tcpreplay -ibond0 -M 5 -l 1 oracle_request_response.cap")
print"+++++++++++++++++++++++++++++++"
print"times:" ,i
time.sleep(5)
#方法二
os.popen
import os
i = 0
while True:
i = i + 1
print os.popen("tcpreplay -ibond0 -M 5 -l 1 oracle_request_response.cap").read()
print"+++++++++++++++++++++++++++++++"
print"times:" ,i
time.sleep(60)
#方法三
output = Popen("xxx",shell = True).communicate()[0]
import os
from subprocess import *
i = 0
while True:
i = i + 1
output = Popen("tcpreplay -ibond0 -M 5 -l 1 oracle/*",shell = True).communicate()[0]
print"+++++++++++++++++++++++++++++++"
print"times:" ,i
time.sleep(60)