Re: How to programmatically open new screen window?

Jean Louis <[email protected]>
Newsgroups gmane.comp.gnu.screen.user
Message-ID <[email protected]>
On Fri, Dec 23, 2016 at 08:42:46AM -0800, Neal Fultz wrote:
> > Some screen commands can send their output to stdout, others don't, but
> > there are ways to fake it.  This will give you the session name for the
> > current screen session:
> >
> >
> > -- snippet --
> > # get the sessionname for our current screen
> > screen -X sessionname
> > session=$(screen -X -Q lastmsg | awk '{print $NF'} | tr -d \')
> > -- end snippet --
> >
> > You can then use this output to send commands to this screen session:
> >
> > -- snippet --
> > # create a new screen window named "newwin"
> > screen -x ${sessionname} -X screen -t newwin
> > # select (change focus to) window "newwin"
> > screen -x ${sessionname} -X select newwin
> > # feed the new window a command-line
> > screen -x ${sessionname} -X at "newwin" stuff "echo hello world^M"
> > -- snippet --

Thank you, those are good pointers. Though the -Q lastmasg refers to
remote screen session.

I would like to get within the screen session the ID of session, and
then within that session to open a new window.

So far this one works within the session, to open a new window:
screen -x 2488.pts-2.protected -X screen -t newwin

How could I non-interactively get the session name from: screen -X
sessionname?

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