Follow-up Comment #1, bug #32623 (project screen):

This issue seriously limit's screen automation. Moreover the 'stuff', 'exec',
'kill' -X commands.
I'm reproducting this problem on FreeBSD 6.4-STABLE and Linux
2.6.26-2-686-bigmem.

I've get to a workaround - reattaching the screen using 'screen -r' and
detaching makes the screen session back controllable.

Example of problem reproduction and workarounds

"I want to spawn 'man ls' and leave running in a screen session"

#10 Create screen session (assume no 'test' sessions exist)
$ screen -d -m -S test
#20 ...but the following will have no effect no mater how many
# times repeated ('stuff' also fails):
$ screen -S test -X exec man ls <RETURN>

#30 But reattaching (as bg job to keep control) and detaching...
#BUG? But sometimes no screen is available to atach to!
$screen -S test -r & sleep 2 ; screen -S test detach <RETURN>
# ...will make the screen controllable!

#40 Now, it works!
$ screen -S test -X exec man ls <RETURN>

So workaround is like this:
$ screen -d -m -S test; screen -S test -r & sleep 2 ; screen -S test detach;
screen -S test -X exec man ls
 
But if I want to spawn screen and leave it running with 'man ls' on a remote
machine using a script that is calling ssh the key workaround part 'screen -S
test -r' will not succeeed because "Must be connected to a terminal", even
'ssh -t', 'ssh -tt' will not help.

So, I spawn ssh in local screen and control this screen in order to execute
desired remote commands via ssh. To spawn command in a local screen from
script I need to use the above workaround.
Finally the local obolete session should be closed but single -X kill command
has no effect... somehow repeated twice succeeds

$ screen -m -d -S test;sleep 2;screen -S test -r&sleep 1;screen -S test -X
detach;screen -S test -X exec ssh user@rmachine; sleep 4;screen -S test -X
stuff "screen -m -d -S test;screen -r&sleep 1; screen -S test -X detach;
screen -S test -X exec man ls"$'x0D'; sleep 2; screen -S test -r&sleep
2;screen -S test -X detach;echo killing;screen -S test -X kill; screen -S test
-X kill 

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?32623>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/


Reply via email to