Write to stdin of a running process using pipe
Just ignore the lines containing nc
, the OP in this questions wants to use it to transfer data over the network via nc
.
That leaves you with:
mkfifo yourfifo
cat > yourfifo &
mypid=$!
yourprogram < yourfifo
Now you can sent data to your program with
echo "Hello World" > yourfifo
If you are done, terminate your program, issue the command kill $mypid
to get rid of the dummy process to keep the FIFO open and rm yourfifo
to get rid of the named pipe.