Hi,

On Sun, Oct 18, 2015 at 11:13:07PM +0000, Anonymous wrote:
> A shell script needs to be able to add a window, and know in advance
> what window number is still available.  It will then do some stuffing.
> 
> ATM it's quite messy and complex.  The script attempts to randomly
> create a title then use that as a handle, but then it must eventually
> rename the window to something sensible.  Sometimes it screws up and
> clobbers an existing window.

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.)

> I need a more sensible option.  E.g. I need to be able to do something
> like "screen -x user/session -windowlist", and simply get a dump of
> windows, which the script can then parse.

Have you tried "screen -Q windows"? Unfortunately it seems to be
truncated to the width of the screen session's bottom line. Luckily it
seems truncated at the beginning, i.e. you always see the highest number:

Get the highest window number:

$ screen -Q windows | sed -e 's/^.*[^0-9]\([0-9][0-9]*\)[^0-9]*\$[^$]*$/\1/'
10
$

Run "mc" in a window with one window number higher than the highest
one (i.e. always a predetermined window number):

$ screen -X screen $(($(screen -Q windows | sed -e 
's/^.*[^0-9]\([0-9][0-9]*\)[^0-9]*\$[^$]*$/\1/')+1)) mc

(needs bash or zsh for $((expression)) to work)

Or separated to reuse the window number elsewhere:

$ windownumber=$(($(screen -Q windows | sed -e 
's/^.*[^0-9]\([0-9][0-9]*\)[^0-9]*\$[^$]*$/\1/')+1))
$ echo Window will be created with number $windownumber
$ screen -X screen $windownumber mc

HTH.

                Kind regards, Axel
-- 
/~\  Plain Text Ribbon Campaign                   | Axel Beckert
\ /  Say No to HTML in E-Mail and News            | a...@deuxchevaux.org  (Mail)
 X   See http://www.nonhtmlmail.org/campaign.html | a...@noone.org (Mail+Jabber)
/ \  I love long mails: http://email.is-not-s.ms/ | http://abe.noone.org/ (Web)

_______________________________________________
screen-users mailing list
screen-users@gnu.org
https://lists.gnu.org/mailman/listinfo/screen-users

Reply via email to