I have this super simple TCP server that takes requests and returns the output of handler.sh:

while true ; do nc -l -p 1234 -e handler.sh; done

I'd like to port the requested path to handler.sh as a parameter, so that if was hit, handler.sh would know.

Is this possible?

Thanks :)

  • Requested path? What do you mean? Some protocol like HTTP that has paths? – phk Jun 18 '16 at 16:30
  • @phk Yes I should have specified I'm working primarily with HTTP. Ideally if an HTTP GET is sent to, handler.sh is executed with parameter "foo/bar" or "/foo/bar" – Nathan Jun 18 '16 at 19:16
  • Well, parsing HTTP isn't that trivial (esp. if you want to do it robust and correctly), a quick internet search revealed that there are indeed HTTP servers written in bash, like github.com/avleen/bashttpd probably too much for you though. – phk Jun 18 '16 at 19:34

Your Answer

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

Browse other questions tagged or ask your own question.