I writing a python app that runs some commands on a gnu screen without joining the screen and seeing the hardcopy buffer. In particular, I am running:
screen -dmS test
screen -S test -p 0 -X stuff "ls$(printf \\r)"
screen -S test -X hardcopy screenOutput.txt
when I look at screenOutput.txt, I see nothing.
However, if I join the screen, and then run hardcopy,
screen -dmS test
screen -S test -p 0 -X stuff "ls$(printf \\r)"
screen -r test
(quit the screen with c-A c-D)
screen -S test -X hardcopy screenOutput.txt
Then I see the output in screenOutput.txt.
Is there a way to get hardcopy to write to the file, without joining the screen?