3

How can i read the content of a xterm or terminal, only by knowing its device number? Similar to moving the mouse over the text.

Redirecting or cloning the terminal output to a file would be an option too, as long it could be done without interacting with commands executed in this terminal. So nothing like 'command > myfile'.

Or is the only way to solve this a print screen with ocr or simulating mouse moves and clicks?

Edit: I m looking for a solution that reads the content regardless of his origin, p.e. 'echo "to tty" > /dev/pts/1'

inselberg
  • 549
  • 3
  • 13
  • 27
  • Maybe the answer of this question http://stackoverflow.com/questions/29987557/xterm-dump-of-full-scrollable-window-content could help you. – Thomas Baruchel Nov 08 '15 at 16:02

1 Answers1

2

The script command may work for you.

"Script makes a typescript of everything printed on your terminal. It is useful for students who need a hardcopy record of an interactive session as proof of an assignment, as the typescript file can be printed out later" - man script

You can even pass script as command when invoking xterm with -e:

ubuntu@ubuntu:~$ xterm -e script
ubuntu@ubuntu:~$ # A new xterm is started.  uname is run, then exit
ubuntu@ubuntu:~$ # The output is captured to a file called typescript, by default:
ubuntu@ubuntu:~$ cat typescript
Script started on Tue 19 Nov 2013 06:00:07 PM PST
ubuntu@ubuntu:~$ uname
Linux
ubuntu@ubuntu:~$ exit
exit

Script done on Tue 19 Nov 2013 06:00:13 PM PST
ubuntu@ubuntu:~$ 
Digital Trauma
  • 15,475
  • 3
  • 51
  • 83