The linux command

nc -l 8090 | (read METHOD URI PROTOCOL ; echo "method: $METHOD" ; echo "path: $URI" ; echo "prot: $PROTOCOL")

listens to port 8090 and when I type something like into my browser it prints out some infos about the HTTP-Request in the terminal. I can type something in the terminal window now which after Ctrl+C will be shown in the browser.

What I want is to pipe the output of the echo commands back to the stdin of nc, so it will be displayed in the browser. Is there any way to do this?

1 Answer 1


Named pipes are your friend!

mkfifo ncloop
nc -l 8090 < ncloop | (read METHOD URI PROTOCOL ; echo "method: $METHOD" ; echo "path: $URI" ; echo "prot: $PROTOCOL") > ncloop

(Tested in OS X 10.8.2 but should work on any Unix.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .