Re: need "windowlist" info externally, not interactively

Anonymous <[email protected]>
Newsgroups gmane.comp.gnu.screen.user
Message-ID <[email protected]>

> Which screen commandline parameters do you use for that? I'd expect
> something like "screen -X screen 63 somecommand". (Would run
> "somecommand" in a window with number 63 unless that number is
> already in use.)

Since writing the original post, I've improved the script.  Now it
does something like:

===8<----------
uid=a$(md5sum <<< "${RANDOM}")
screen -X screen -t "${uid%% *}"
screen -p "${uid%% *}" -X exec script -c env /tmp/window_env.txt
sleep 1; #needed to ensure the file is ready for awk to read
window_num="$(awk -F= '/^WINDOW=/{ print $2 }' /tmp/window_env.txt)"
rm /tmp/window_env.txt
screen -p "$window_num" -X title More-Meaningful-Title-Here
screen -p "$window_num" -X stuff command1$'\r'
screen -p "$window_num" -X stuff command2$'\r'
screen -p "$window_num" -X stuff command3$'\r'
..etc..
===8<----------

One tricky part was coming up with "script -c env
/tmp/window_env.txt", because redirection does not work (initially I
tried simply "env > /tmp/window_env.txt").

In the end, that seems to work.

> Have you tried "screen -Q windows"?

Thanks for that.  I didn't know about the -Q option.  It turns out
that the version of screen available is too old for that, so hacks
still needed.  I was pleased to find that my home machine has -Q
though.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.