3 ms·
while TRUE; do { echo -e 'HTTP/1.1 200 OK\r\n'; cat /path/to/thing; } | nc -l 8000; done From: https://krypted.com/ https://krypted.com/
by arminiusreturns 7y ago
while TRUE; do { echo -e 'HTTP/1.1 200 OK\r\n'; cat /path/to/thing; } | nc -l 8000; done
From: https://krypted.com/ https://krypted.com/
- ainar-g 7y agoNeither echo -e nor nc are POSIX. I don't think there is a strictly POSIX one-liner.
- arendtio 7y ago`echo -e` should be easily replaceable with `printf` but nc remains to be a problem.
- tyingq 7y agoIs 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.
- deleted 7y ago[deleted]
- arendtio 7y agoI doubt it. At least I can't find it anywere here: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/contents.html https://pubs.opengroup.org/onlinepubs/9699919799/utilities/c...
- ksherlock 7y agoprintf(1) is POSIX and is a superset of echo.
- arminiusreturns 7y agoYou are right, but it was the closest I could find.