[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to programmatically open new screen window?
From: |
Jean Louis |
Subject: |
Re: How to programmatically open new screen window? |
Date: |
Fri, 23 Dec 2016 20:44:11 +0300 |
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