I have a Python script test.py
that only contains: print('hi')
. I want to run it in a screen
so that the output of the screen
is saved by script
.
I use the following command to run test.py
in a screen
, it works fine:
screen -dm bash -c 'python test.py'
However, I haven't managed yet to find a way to use script
to save the output of the screen
. How can I do it?
I unsuccessfully tried:
script -c "screen -dm bash -c 'python test.py'" output.txt
: the output file output.txt doesn't containhi
, but only:Script started on Fri 26 Aug 2016 01:04:59 PM EDT Script done on Fri 26 Aug 2016 01:04:59 PM EDT
I use Ubuntu 14.04.4 LTS x64.
Documentation:
https://www.gnu.org/software/screen/manual/screen.html:
-d -m: Start screen in detached mode. This creates a new session but doesn't attach to it. This is useful for system startup scripts.
http://linux.about.com/library/cmd/blcmdl1_sh.htm :
-c string: If the -c option is present, then commands are read from string. If there are arguments after the string, they are assigned to the positional parameters, starting with $0.
script's man page:
-c, --command run command rather than interactive shell