Search code examples
linuxcatttyprocfs

How to redirect input from another tty?


When i run cat - in say /dev/pts/2 and try to write to its input from another tty with echo foo > /dev/pts/2 or echo foo > /proc/(pid of cat)/fd/0 it just prints foo in pts/2, cat doesn't repeat it . why? How to send input to cat from another tty so it also repeat it ?


Solution

  • I think there is a fundamental misunderstanding here: you cannot inject content to another TTY's input stream (unless you own the master).

    You can, however, call cat /dev/pts/0 to read from another TTY's input stream, but beware that you will be fighting whatever process is already there.