1
У меня есть два файла:Python стандартный вывод и подпроцессы
run.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)
Что я и как я могу получить все для вывода, как первая команда?
Ах, и оба тройника и перенаправление в файл делают буфер не линейным, а просто работают с tty flushes на каждой строке. Благодаря! – theicfire