, script . , stdout, stderr /dev/tty python script :
brent@battlecruiser:~$ cat test.py
import sys
sys.stdout.write('o\n')
sys.stderr.write('e\n')
with open('/dev/tty', 'w') as tty:
tty.write('t\n')
brent@battlecruiser:~$ script testout
Script started, file is testout
brent@battlecruiser:~$ python test.py
o
e
t
brent@battlecruiser:~$ exit
Script done, file is testout
brent@battlecruiser:~$ head -n -3 testout | tail -n +3
o
e
t
, , 2>1& tee:
brent@battlecruiser:~$ python test.py 2>&1 | tee testout
e
t
o
brent@battlecruiser:~$ cat testout
e
o
, /dev/tty . script, , , .
source
share