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:
    pass
How to get linux screen title from command line