I’ve been trying to come to terms with scripting in GNU Screen. Upon reading the man pages and a few other examples, I understand that we can use the at command or the -X argument for sending commands to screen sessions.
Let me explain my situation. I need to write a script that runs from with in an existing screen session. This script should create new windows, set their titles, browse to a specific directory and run a program in each of these windows.
The problem with the at command is that I can only send one command at a time. When I create a new window using at command, it will not be possible for me to obtain the window number of that newly created window. Because of this, I will not be able to send any more commands to that new window. How can I retrieve the window number of this new window?
On creating a new
screenwindow you can specify a name with-t(e.g.-t test) and send commands via-Xto this specific screen by using the additional parameter-p(e.g.screen -p test -X eval 'yourcommand --yourparameter')