python shell中怎么重复执行命令
1个回答
展开全部
有三种方法:
1、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)
2、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)
3、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)
1、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)
2、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)
3、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)
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询