Date: Fri, 04 Apr 2003 07:18:18 +1000
From: Gregory White <glwhite@netconnect.com.au>
Subject: Re: tty
To: Linux Users Of Victoria <luv@luv.asn.au>
                                                                                
Paul Arch asked:
> can you somehow 'capture' the output from a tty? specifically I have
> some output on tty12 that would be good to capture to a file.  Or
> perhaps even 'tail' it ?

A neat and nifty trick, is that any tty can be saved and restored easily.
From a program or script, to save or restore a console(tty) open up the
following device (file spec):

/dev/vcs#     (where # is the tty number)

When you read the device, the current contents of the tty are saved.
When write a saved tty file to the same device/file spec.

Greg White



RM adds:  Here's the relevant excerpt from the kernel source code
Documentation/devices.txt file:

  7 char        Virtual console capture devices
                  0 = /dev/vcs          Current vc text contents
                  1 = /dev/vcs1         tty1 text contents
                    ...
                 63 = /dev/vcs63        tty63 text contents
                128 = /dev/vcsa         Current vc text/attribute contents
                129 = /dev/vcsa1        tty1 text/attribute contents
                    ...
                191 = /dev/vcsa63       tty63 text/attribute contents

                NOTE: These devices permit both read and write access.