Greetings all,
I'm having trouble giving a detached screen a command from another shell. Is this possible?
Here's what I've done:
In window 1, I setup a screen like this:
Code:
$ screen -d -m -S hawktest01
This starts a bash shell in a detached screen, and it appears in the screen list:
Code:
$ screen -ls
There is a screen on:
25704.hawktest01 (Detached)
1 Socket in /home/jedihawk/.screen.
Now, if I attach to it like this:
Code:
$ screen -r hawktest01
I get the screen session and my bash prompt and all is well. Then I hit Ctrl-A D to detach and I'm back where I was.
From window 2, I run:
Code:
$ screen -S hawktest01 -X readreg 1 hawk
This sends a command to the screen with the name 'hawktest01', which I just setup in window 1. The command tells screen to read the contents of the file 'hawk' and put it into register 1, which is just a temporary user space, like a copy buffer. The contents of the file 'hawk' is 'hawk'; I'm keeping this simple.
I follow this command with another:
Code:
$ screen -S hawktest01 -X process 1
This command puts the contents of register 1 into the keyboard buffer, as if the user had typed it.
The problem is that if the screen in window 1 is detached, the above two commands don't work--but they also don't give any indication that they didn't work.
If, however, I re-attach to the screen session in window 1:
Code:
$ screen -r hawktest01
And then I run the above two commands again from window 2:
Code:
$ screen -S hawktest01 -X readreg 1 hawk
$ screen -S hawktest01 -X process 1
The word 'hawk' appears in window 1, as it should. Basically, I'm commanding another screen session from remote (but I'm on the same machine). This procedure doesn't seem to work if the screen session in window 1 is detached.
Is it possible to send commands to a detached screen session?
-Hawk