I have a binary that I'm debugging remotely, one way for me to send input to that file is throw
echo "input" > /proc/pid/fd/0
when I do the above the input is been received by the binary but I can't simulate a keypress, and that causes me to switch to that binary and press enter every time.
here is an example
#include <stdio.h>
int main () {
char str[50];
printf("Enter a string : ");
gets(str);
printf("You entered: %s", str);
return(0);
}
when you run the above program and send the input using
echo "input" > /proc/pid/fd/0
the above program will receive the input but it will not press the enter key
so is there is a way to do it using the file descriptor of the binary or any quick way?
in my case keypress is just the enter key
edit:
echo -en 'input\r' > /proc/pid/fd/0
or
echo -en 'input\x0d' > /proc/pid/fd/0
won't work because the terminal will think it's the slave sending that to the output it will not be sent to slave's stdin