- 論壇徽章:
- 0
|
本帖最后由 mstools 于 2013-05-15 17:39 編輯
我有一個(gè)腳本,,腳本如下
#!/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()
執(zhí)行腳本的時(shí)候,,我加了-u的選項(xiàng),,不緩沖數(shù)據(jù),,
但是輸出的結(jié)果仍然是先輸出subprocess里面的結(jié)果再輸出hello和"this is end"
求大神幫忙解決,,
讓腳本先輸出"hello"再輸出subprocess再輸出"this is end" |
|