Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 http://127.0.0.1:8090/path/to/nowhere 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?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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.)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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