# 环境:macosx、stackless python & twisted
cmd = '/users/xxx/.../xx.sh' # 全路径或者./相对路径
import subprocess
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
while p.poll() == None:
line = p.stdout.readline()
print line # 必须执行print,否则一直不返回,原因不明
result = result + line
python 执行sh脚本文件
最新推荐文章于 2024-07-15 03:43:46 发布