I am running a Node.js script that prompts (via lib) user for a code. I get the process id of the script:
pgrep -f test.js
and then pass it the code with a new line to simulate Enter key:
echo -e "1234\n" > /proc/88888/fd/0
The code 1234
gets passed, a new line is added as well, but it didn't trigger Enter key and the script does not proceed. However, when I manually press Enter key in shell, the script does recognise the Enter key. So the question is how can I reliably send Enter key to another process/script?