Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )



Advanced DNS Management
New ZoneEdit. New Managment.

FREE DNS Is Back

Sign Up Now
 
Reply to this topicStart new topic
> Screen Help, commanding 'screen' from elsewhere
jedihawk
post Jul 15 2005, 01:19 PM
Post #1


Whats this Lie-nix Thing?
*

Group: Members
Posts: 2
Joined: 15-July 05
Member No.: 5,275



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 if the screen session in window 1 is detached.

Is it possible to send commands to a detached screen session?

-Hawk
Go to the top of the page
 
+Quote Post
jedihawk
post Jul 20 2005, 10:18 AM
Post #2


Whats this Lie-nix Thing?
*

Group: Members
Posts: 2
Joined: 15-July 05
Member No.: 5,275



Well, it seems that commanding a detached screen from another terminal won't work unless using something like:

CODE
screen -S hawktest01 -X exec .!. echo ls


But this opens up a subprocess which pipes the output to the shell, which won't work for my purposes because I'm trying to run a program with an interactive macro.

However, if I setup a series of commands which switch virtual windows within the same screen session, then all works very well. For example, I have two virtual windows open, then I run my script from virtual window 0 and it's setup to switch to virtual window 1 and run the program. That's good because I can watch what's happening as it goes along.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 19th October 2017 - 07:55 AM