I'm trying to send an arrow key via the stdin to the bash:
cat | /bin/bash
then i am typing "echo hi" => "hi" appears on the console (of course without the quotes) then i press the arrow key up => ^[[A command not found appears
Is it possible to send an arrow key to an program via the stdin ?
The reason why i am asking is: I want to control the bash from another programm. I would like to send arrow keys to the bash
What you really should be doing is create a pseudo-tty device (using openpty() or similar), start bash on that PTY, and send your key strokes through that PTY device. See the section on “Pseudo-Terminals” in the GNU C Library Manual.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With