I have a simple python script test.py:
from __future__ import print_function
print("Hello")
I try to redirect the printing to a file, inside a screen session. The following things work:
Without screen:
python test.py > out.txt
With screen, step by step:
screen -S tmp
python test.py > out.txt
exit
However what I really need is not working (out.txt remains empty):
screen -Sdm tmp python test.py > out.txt
After reading a seemingly related question I also tried:
screen -Sdm tmp stdbuf -i0 -o0 -e0 python test.py > out.txt
But it also didn't work.