screen-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Running command to different screen


From: Phil!Gregory
Subject: Re: Running command to different screen
Date: Thu, 20 Jul 2006 08:48:55 -0400
User-agent: Mutt/1.5.11+cvs20060403

* Mag Gam <address@hidden> [2006-07-20 07:55 -0400]:
> Is it possible to run a command to a different active screen terminal?

Yes.  Use the screen command 'at'.

> If I have 4 different virutal terms open, and I want to run 'df -h' on all
> of them at the same time....

The second parameter to 'at' is an identifier that matches either a
window, a user, or a display terminal.  It matches it as a prefix, so it
is possible to construct commands that will match multiple times.  If
those four windows are all you have, you can use 'at # ...', which will
match all of your windows.  If you have windows that you don't want to
receive the command, you need those four to have the same title.  In my
setup, any window running a shell has a title of "zsh", so for my system
I'd use 'at zsh# ...'.

For getting commands to run in shells inside screen, the screen command
you need to use is 'stuff'.  To run 'df -h', you'd use 'stuff "df -h ^J"'
where "^J" is a quoted control-J (or enter) character.  I couldn't manage
to get the ^J entered from screen's colon mode, though.  I think there's a
way to define aliases for commands, but I can't find it at the moment.
The best thing to do would be to use an editor to create a file
containing:

  at zsh# stuff "df -h^J"

and then, in screen, run

  source <filename>

You can also run, from the command line:

  screen -X at zsh\# stuff "df -h^J"

since shells will generally let you quote control characters.

-- 
...computer contrarian of the first order... / http://aperiodic.net/phil/
PGP: 026A27F2  print: D200 5BDB FC4B B24A 9248  9F7A 4322 2D22 026A 27F2
--- --
Hello, my name is Inigo Montoya, you killed my father, prepare to die.
                       -- Inigo (_The Princess Bride_, William Goldman)
---- --- --




reply via email to

[Prev in Thread] Current Thread [Next in Thread]