8

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.

13

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.

  • 2
    what is cat > yourfifo & doing? – Alexander Mills Jul 11 '17 at 5:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.