I am making a python program that launches on bootup. I would like it so that I can interact with that program via the "screen" command. Then, if I need to talk to the program via a different tty, ssh, or something then I would be able to.
I like to keep it so I can just use a bash script to attach the screen in my terminal, instead of having to look up where it is—as I need other people (who don't use the terminal) to be able to access it.
Best Answer
The surest way to attach to the right screen session is for the Python script to write to a designated file to report which
screen
session it is running in. Think of it as something analogous to a PID file, except that you are reporting the TTY rather than the process ID. Otherwise, if multiplescreen
sessions exist, there's going to be guesswork involved.So, when launching the Python process, run
… or from within the Python program itself,
Then, users can attach to it by running