Hacker News new | past | comments | ask | show | jobs | submit login

Does someone know if there is a way of doing this purely with POSIX tools?



  while TRUE; do { echo -e 'HTTP/1.1 200 OK\r\n'; cat /path/to/thing; } | nc -l 8000; done

From: https://krypted.com/


Neither echo -e nor nc are POSIX. I don't think there is a strictly POSIX one-liner.


`echo -e` should be easily replaceable with `printf` but nc remains to be a problem.


Is inetd "Posix"? It has command line switches to not fork, and to specify the config file. Maybe it takes a config file of "-" to mean stdin.


I doubt it. At least I can't find it anywere here:

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/c...


You are right, but it was the closest I could find.


printf(1) is POSIX and is a superset of echo.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: