1

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

but

$ 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?

2
  • 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
    Dec 20, 2018 at 20:18
  • to achieve = send ENTER from stdout one to another process stdin Dec 20, 2018 at 20:27

0

Browse other questions tagged .