linux - write commands from one terminal to another

前端 未结 7 1650
刺人心
刺人心 2020-12-29 09:54

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/         


        
7条回答
  •  猫巷女王i
    2020-12-29 10:07

    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).

提交回复
热议问题