Skip to content

Instantly share code, notes, and snippets.

@Happy-Ferret
Forked from macedd/write-stdin.sh
Last active January 23, 2017 17:57
Show Gist options
  • Save Happy-Ferret/34ad7f2ccc15696d80d6adf7d76f8e60 to your computer and use it in GitHub Desktop.
Save Happy-Ferret/34ad7f2ccc15696d80d6adf7d76f8e60 to your computer and use it in GitHub Desktop.
Write to STDIN of running Process
## Alternative 1: write to file descriptor (not usable)
input='testing'
pid=1212
echo $input > /proc/$pid/fd/0
## Alternative 2: Pipe fifo to the app
fifo_file=/tmp/fifo
mkfifo $fifo_file; cat > $fifo_file &; echo $! > {$fifo_file}.pid
(cat $fifo_file | myapp)
echo "testing" > $fifo_file
kill -9 `cat $fifo_file.pid` && rm $fifo_file*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment