我有两个文件:
运行.py
import subprocess
import time
while True:
time.sleep(1)
print 'hello'
proc = subprocess.call(['./writer.sh'])
writer.sh (chmod 777'd)
#!/bin/sh
echo 'write something here'
我对以下输出感到困惑:
$ python run.py
hello
write something here
hello
write something here
hello
write something here
....
$ python run.py | tee out.log
write something here
write something here
(hello disappears)
....
$ python run.py > out.log
# Nothing, but out.log has the following:
write something here
write something here
write something here
write something here
hello
hello
hello
hello
... # and the two basically "expand" the longer I run this (instead of appending)
发生了什么,我怎样才能像第一个命令一样输出所有内容?