Find the answer to your Linux question:
Results 1 to 7 of 7
So, I need a way to have screen (or dbus, whatever) to spit out a list of windows (title and number) that are active in a screen session. I'm writing ...
  1. #1
    Just Joined!
    Join Date
    May 2011
    Posts
    3

    Screen listing of windows in a session

    So, I need a way to have screen (or dbus, whatever) to spit out a list of windows (title and number) that are active in a screen session.

    I'm writing a wrapper for common work tasks. Part of the functionality will check if a certain window exists, and if so let me know. The idea here is to prevent accessing the same machine twice. (although, and override option would probably be needed, just in case, but I digress...)

    I've searched through the screen man page and don't see anything that'll work. I'm not beyond forking screen and ending up with a custom version. However, I'd like to avoid that if I can.

    Thoughts?

    Edit: Ideally, I'd like to see something like "screen -S screen_name -window-list" or similar.

  2. #2
    Just Joined!
    Join Date
    May 2011
    Posts
    44
    What's wrong with screen -ls

    You could potentially (untested):
    Code:
    #!/usr/bin/perl
    use strict;
    use warnings;
    
    my @screens = split/\n/ `screen -list`;
    shift @screens;
    pop @screens;
    
    print "$_ \n" foreach @screens;

  3. #3
    Just Joined!
    Join Date
    May 2011
    Posts
    44
    ok, it works, but I missed a comma, also, you need to pop screens twice as the output ends with two new lines:

    as a one liner:
    Code:
    perl -e 'my @screens = split/\n/[b],[\b] `screen -ls`; pop @screens for (1 ..2); shift @screens; print "$_ \n" foreach @screens;'
    expanded:
    Code:
    #!/usr/bin/perl
    use strict;
    use warnings;
    my @screens = split/\n/, `screen -ls`; 
    pop @screens for (1 ..2); 
    shift @screens;
     
    print "$_ \n" foreach @screens;'

  4. #4
    Just Joined!
    Join Date
    May 2011
    Posts
    3
    That's the same as 'screen -list', sans parsing.



    Code:
    [shellbox.xen][~]
    ag-> perl test.pl
    	2828.ag	(Attached) 
    [shellbox.xen.andrewglenn.net][~]
    ag-> cat test.pl
    #!/usr/bin/perl
    use strict;
    use warnings;
    my @screens = split/\n/, `screen -ls`; 
    pop @screens for (1 ..2); 
    shift @screens;
     
    print "$_ \n" foreach @screens;
    [shellbox.xen][~]
    ag-> screen -list
    There is a screen on:
    	2828.ag	(Attached)
    1 Socket in /var/run/screen/S-ag.
    In that screen, are 9 or 10 _windows_. The same output as 'windowlist -b' or C-a " in screen. I need that to be blasted to a shell so I can manipulate as needed.

    Edit: Grammatical Errors.

  5. #5
    Just Joined!
    Join Date
    May 2011
    Posts
    44
    Quote Originally Posted by ragechin View Post
    That's the same as 'screen -list', sans parsing.
    Yes, I believe that screen -ls is an alias for screen -list.

    Quote Originally Posted by ragechin View Post
    In that screen, are 9 or 10 _windows_. The same output as 'windowlist -b' or C-a " in screen. I need that to be blasted to a shell so I can manipulate as needed.
    sorry can't help here. What utility has the windowlist command? Unrecognized in my system (and my brain...)

    Still not clear on what you are looking for. Are you using Screen to manage an X Window session and that x window session has multiple windows?

  6. #6
    Just Joined!
    Join Date
    May 2011
    Posts
    3
    As per goo.gl/RoNko
    Code:
    C-a "
    (windowlist -b)
    Present a list of all windows for selection. See Selecting.
    Example screenshot: i52.tinypic.com/35iujqq.png

    I need that to be tossed to STDOUT so I can parse it...

  7. #7
    Just Joined!
    Join Date
    May 2011
    Posts
    44
    Ok, I see now. I can get the C-a " to work but I am still unsure of how `windowlist -b` works. (I imagine it is a command instead of a shortcut that calls the same procedure...) My thinking is that understanding this function call is the key to understanding how screen outputs its message.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...