Skip to content

Instantly share code, notes, and snippets.

@h3llix
Forked from macedd/write-stdin.sh
Created September 5, 2022 07:47
Show Gist options
  • Save h3llix/eabd465939d20458740aa5efc8206873 to your computer and use it in GitHub Desktop.
Save h3llix/eabd465939d20458740aa5efc8206873 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