Is there a way to list the windows of a screen session from a non-interactive terminal?
screen -S 'screen_name' -X windows
According to gnu.org, this command displays the list of windows using the message line.
That's fine and dandy for an interactive console, but I need this to print to standard output so I can read it into another program.
Any way to do this?
I found that the best way to do this is to get the list of windows ids by using this command: (as posted by Stephen Harris)
screen -S 'pid.screen_name' -Q windows
Although this truncates the names of the windows when it prints, it doesn't actually truncate the total size of the output. So if I have like 20 windows in a screen session, this is what the output will be.
> screen -S 'pid.screen_name' -Q windows 0 bash 1 bash 2 bash 3 bash 4 bash 5 bash 6 bash 7 bash 8 bash 9 bash 10 bash 11 bash 12 bash 13 bash 14 bash 15 bash 16 bash 17 bash 18 bash 19 bash 20 bash
I have tried this up to an absurd number of windows.
With this you can parse how many windows there are in the screen session, and then issue a "title" command for each one using the following command:
screen -S 'pid.screen_name' -p %window_id% -Q title
%window_id% with each window ID from the
This time the window title isn't truncated at all. So the full screen name is outputted to standard output.