Jas Eckard
unread,Jul 15, 2021, 4:58:18 PM7/15/21Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to UCLUG
I was listening to a podcast today, and one of the things the guest
talked about was "back in the day" he created a website that was
basically a blog. In that blog, he would journal the things he
recently learned, including the mistakes he made along the way. That
got me reminiscing about "the old days" in this group. We used to do
that. Linux was new, and we didn't have a lot of resources to go to.
No Stack Exchange (Server Exchange), and no Google. I used to do it
with UCLUG, but I got "busy". Well, I'm going to try to do it again.
So, here's something I learned yesterday:
I had to ssh to a bunch of servers, and send basically the same
commands to all of them at the same time. Normally, I would use
`clusterssh` to do that (if I don't already have `SaltStack` or
`Ansible` setup), but I was already connected to all of them from the
jump server inside one `screen` session. Wouldn't it be great if,
like in `clusterssh`, you could send a command to all your `screen`
windows? Wait, maybe you can.
I eventually found the answer (yes, on Server Exchange, but it had a
link to a blog post). I looked in the man page, sure enough, it's
there, I just didn't know what to look for.
TL;DR:
While in the screen session (I re-attached, for example), type:
<CTRL-A>:at '#' stuff "command args^m"
To break it down:
- <CTRL-A> - Chord the <CTRL> key and the letter 'a' (this is the
"signal" to `screen` that the next command is for it).
- : - The colon character brings up a `screen` commandline (similar to
what `vi` does).
- at - The `at` command sends something to the specified screen "windows".
- '#' - There's some sort of complicated way of specifying which
"windows" you want, but I figure I'll always want to send to all of
them, and that's what singlequote-pound-singlequote does.
- stuff - The `stuff` command is a thing that does a thing, it says
what in the manual, but I TD;DR'd, I just know I always need the word
"stuff" (I assume it's the verb form of "stuff").
- "command args^m" - This is the command and args that I want to send
to every "window". This seems to follow shell quote interpretation,
so single- vs double-quotes are important. And quoting is not
necessary if I don't need to send arguments to a command, for example,
or I'm just answering "yes" to a prompt. If I want to send special
characters, use the caret-form. In this example caret-M (`^M` or
`^m`, I discovered it's case-insensitive) sends a carriage return
(<CR> or '\r'). I use `man ascii` for reference for caret-form.
--Jas
.
..: