Example process waiting an input sent to background

$ read -p "Input text and hit ENTER to exit" &

I try to write to stdin (fd/0) with \n

$ echo -e "ok\n" > /proc/$!/fd/0


$ fg

read -p "Please hit ENTER"

so the process is still running, then string "ok\n" never reach it

How can I send a string+ENTER to another process STDIN?

  • What to you want to achieve with that? Maybe another way would also be OK (like setting a default value before, and use timeout parameter -t for read)?
    – Jaleks
    Commented Dec 20, 2018 at 20:18
  • to achieve = send ENTER from stdout one to another process stdin Commented Dec 20, 2018 at 20:27


Browse other questions tagged .