Suppose you have a terminal emulator (T1) open with a PID of 6350.
From another terminal, type this command (C1):
echo "ls\n" > /proc/6350/fd/0
This writes ls
and the new line in T1 but does not execute it. Why?
I also tried using cat|bash
with echo "ls\n" > /proc/catid/fd/0
but it is still not executed.
How can I echo the command into another terminal and have the command executed?
possible answer :
$ mkfifo toto;
$ bash < toto;
$ echo "ls" > toto;
In this case you cannot write anymore directly in the terminal (everything is displayed the same way the command (C1) displayed thing in this terminal.
Best Answer
There is a command line utility called
ttyecho
that can send a command to another terminal (tty/pts) and have the command executed.See: Utility to Send Commands or Data to Other Terminals (tty/pts)
Also see:
ttyecho
source code on github.Another interesting tty command is
selector
, a real-time interactive pattern matcher in console that updates the tty input buffer.See: selector - DYNAMIC SEARCH IN CONSOLE