4 ms·
Paul Buchheit: Webserver written in bash - under 20 lines of code
- staunch 20y agoNice hack. "And not using perl or any of that fancy stuff" I think netcat counts as fancy stuff. Here's the example scripts netcat is packaged with: http://darwinsource.opendarwin.org/10.3/netcat-4/netcat/scripts/ http://darwinsource.opendarwin.org/10.3/netcat-4/netcat/scripts/ Powerful little tool.
- paul 20y agoThanks. Nc is a little bit fancy, but nothing compared to perl. It's also installed by default on both linux (my linux, anyway) and osx. However, the nc installed on OSX doesn't have the "-e" "gaping security hole" option compiled in, meaning that those example scripts (or at least the one I looked at) won't work. I do wish that there was some way to do this without nc though. Maybe the linux proc filesystem enables net access? Oh well, another day...
- ralph 20y agoYou're right, network sockets should be part of the filesystem. Arnold Robbins, author of GNU awk, is a fan of Plan 9 which did this the right way. It was probably the motivation for him adding special files to awk, e.g. "/inet/tcp/0/localhost/17921". $ nc -l -p 17921 & [1] 31333 $ date | awk '{print NR, NF [greater than sign]"/inet/tcp/0/localhost/17921"}' 1 4 [1]+ Done nc -l -p 17921 $ http://www.gnu.org/software/gawk/manual/gawkinet/gawkinet.html http://www.gnu.org/software/gawk/manual/gawkinet/gawkinet.html has more examples. Perhaps there's a FUSE module which gives us a network sockets filesystem? Cheers, Ralph. P.S. It's annoying that posters should waste their time probing the mark-up's flaws. Is there a description of it anywhere, e.g. what characters vanish, or how to break lines?
- jey 20y agoWhat if you were to run under inetd or djb's tcpserver?