screen-users
[Top][All Lists]
Advanced

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

Re: need "windowlist" info externally, not interactively


From: Axel Beckert
Subject: Re: need "windowlist" info externally, not interactively
Date: Mon, 19 Oct 2015 20:47:34 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

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            | address@hidden  (Mail)
 X   See http://www.nonhtmlmail.org/campaign.html | address@hidden (Mail+Jabber)
/ \  I love long mails: http://email.is-not-s.ms/ | http://abe.noone.org/ (Web)



reply via email to

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