Reputation: 2311
In a Python 3 program of mine, I open a GNU screen session at some point. Upon closing this session, the output
[screen is terminating]
is printed to the surrounding session (the terminal in which the python program is run). How do I prevent this?
I am currently running something like
import subprocess
subprocess.run('screen',stdout=subprocess.PIPE,stderr=subprocess.PIPE)
Usually, the [stdout,stderr]=subprocess.PIPE
captures the output and err (e.g. for run('echo hello',stdout=subprocess.PIPE)
nothing is printed) but for some reason this doesn't work with screen
Upvotes: 0
Views: 252
Reputation: 5354
You should capture stderr
as well as stdout
, if you don't want anything printed on the console.
Screen
may also be detecting that stdin
is a tty and using that for I/O. I don't know if giving it a pipe or /dev/null
will solve the problem, though. Try it and see if it works.
Screen
most likely needs access to a tty
device to work. You could create a tty for it (by opening /dev/ptmx
and giving screen
the corresponding /dev/pts/N
file), but that's by no means trivial.
Upvotes: 2