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.
Related videos on Youtube
aditya
Updated on September 18, 2022Comments
-
aditya over 1 year
I am in a similar situation as in this post But I couln't get the solution provided there to work in my situation as the answer seems related to that question only.
In particular, I couldnt understand what was the purpose of
cat my.fifo | nc remotehost.tld 10000
In my case, I have a process running and waiting for input. how can I send input to that process using named pipes?
I've tried
echo 'h' > /proc/PID/fd/0
it just displays 'h' on the process' window. -
Alexander Mills almost 7 yearswhat is
cat > yourfifo &
doing?