To create a screen, I am currently doing:
screen -dmS screenname ./file
That works perfectly, however killing it remotely with:
screen -X -S screenname exit
Will reply with:
No screen session found
This is due to the screen having {session#}.{screenname}
It will work if done as:
screen -X -S session#.screenname exit
What solutions are possible? I'm not entirely sure that you can get the session# when you start the screen. This is all done remotely too.
I also start screens with the -dmS option, and I send commands to the screen using the stuff command:
$ screen -dmS screenname
$ screen -ls
There is a screen on:
22941.screenname (Detached)
1 Socket in /var/run/screen/S-user.
$ screen -S screenname -p 0 -X stuff "exit$(printf \\r)"
$ screen -ls
No Sockets found in /var/run/screen/S-user.
$
more details on "stuff" are in the screen man page, search for 'stuff string'