- 论坛徽章:
- 0
|
本帖最后由 mstools 于 2013-05-15 17:39 编辑
我有一个脚本,,脚本如下
#!/usr/bin/env python
import subprocess
import sys
f = open("/tmp/testaa.log","w")
sys.stdout=f
sys.stderr=f
print "hello"
subprocess.call("ssh 192.168.10.160 'ls -l /tmp'",shell=True, stdout=sys.stdout, stderr=sys.stdout)
subprocess.call("ssh 192.168.10.160 'ls -l /tmpaa'",shell=True, stdout=sys.stdout, stderr=sys.stdout)
print "this is end"
f.close()
执行脚本的时候,,我加了-u的选项,,不缓冲数据,,
但是输出的结果仍然是先输出subprocess里面的结果再输出hello和"this is end"
求大神帮忙解决,,
让脚本先输出"hello"再输出subprocess再输出"this is end" |
|