How to get linux screen name from command line

How can I get the screen session header from the command line?

+7
source share
1 answer

I came up with a very small and simple python script with pexpect to do this.

This is convenient in multi-user environments where some kind of host is reserved, and the status is written to the screen name of the user. This works for me, feel free to do it better. To get a specific session header, you need to modify the script and call the correct session.

If you run this over a remote connection as a local script (e.g. via SSH), be sure to set export TERM=xterm before executing.

 try: import pexpect import sys child=pexpect.spawn('screen -x') child.sendcontrol('a'); child.send('A'); i = child.expect('Set window.*') child.sendcontrol('c'); child.sendcontrol('a'); child.send('d'); TITLE=str(child.after) TITLE_P=TITLE.split('7m') if str(TITLE_P[-1]) == '': print 'Title not found' else: print str(TITLE_P[-1]) except: print 'Could not check screen Title' 
+1
source

All Articles