I need to write commands from one terminal to another terminal.
I tried these:
echo -e \"ls\\n\" > /proc/pid/fd/0
echo -e \"ls\\n\" > /dev/pts/
This is the wrong way to go about it - you might get it displayed in the terminal, but not executed.
You will need to do something like tell a shell to read from a named pipe, or from netcat/socat. Or you could try injecting keystrokes as root or using xtest (there's also sometimes another way under X which I forget).