News for hackers. Stuff that matters.
Re:CGI with Awk on OpenBSD Httpd (2020) by mkovach on Tuesday May 04, 2021 @09:33AM (#27037377)
When I had a requirement to do this, I used the one true awk and compiled it statically. Didn't require mucking around with all the libraries.
Re:CGI with Awk on OpenBSD Httpd (2020) by torstenvl on Tuesday May 04, 2021 @09:25AM (#27037311)
I like obhttpd and would like to migrate to it eventually. Cool project!
Re:CGI with Awk on OpenBSD Httpd (2020) by Voline on Tuesday May 04, 2021 @04:43PM (#27042647)
I have several servers running it, and I’ve been pretty pleased with it. If you want to try it out you can get an OpenBSD VM at Vultr or OpenBSD.amsterdam for about $6/month.

I also highly recommend Michael W Lucas’s book Relayd & Httpd Mastery.

Re:CGI with Awk on OpenBSD Httpd (2020) by torstenvl on Tuesday May 04, 2021 @06:41PM (#27043763)
One thing keeping me on Apache I stead of NGINX or obhttpd is how easy it is to do overrides for particular directories. I use this A LOT for generating dynamic content.

Example: Let's say I want to generate an RTF doc for a power of attorney. I'll tell Apache via .htaccess to treat .rtf documents in that directory as CGI scripts. poa.rtf then is a Python script to process the QUERY_STRING or POST parameters into an RTF template and spit it out. End result is that browser requests poa.rtf and gets a file called poa.rtf -- generated on the fly.

Do you have an idea how you'd accomplish the same trickery in obhttpd? I guess you'd have to have the per-directory config in the main config file?

Re:CGI with Awk on OpenBSD Httpd (2020) by hibbelig on Tuesday May 04, 2021 @09:15AM (#27037220)
Using awk to run CGI scripts is a cool idea. Awk is underrated :-)
Re:CGI with Awk on OpenBSD Httpd (2020) by pantulis on Tuesday May 04, 2021 @09:29AM (#27037342)
I did that 20 years ago with Solaris. Was contrived and not the easiest thing, but work it did.
Re:CGI with Awk on OpenBSD Httpd (2020) by cyberpunk on Tuesday May 04, 2021 @11:21AM (#27038541)
I once inherited one such system, it was running on 2.5.1.. My job was to move it to a zone on s10.. It actually pretty much worked, I had to port it forwards to S8, but then word got around that someone had done 'something' to this ancient pile of tech debt and feature requests started coming in so I rewrote it all in perl in an afternoon.. I didn't even try to understand the code, I just used tcpdump to look at the requests/responses and treated it as a black box.

I don't miss this kind of work ;)

Re:CGI with Awk on OpenBSD Httpd (2020) by pantulis on Tuesday May 04, 2021 @04:37PM (#27042585)
There has been a lot of advances all these years, thank $DEITY.
Re:CGI with Awk on OpenBSD Httpd (2020) by nwmcsween on Tuesday May 04, 2021 @12:29PM (#27039409)
Maybe use with https://github.com/nwmcsween/tawk

sample index.html.tawk which can generate index.html

```` <p> {{! cat /proc/cpuinfo }} </p>

````

Re:CGI with Awk on OpenBSD Httpd (2020) by throwawayboise on Tuesday May 04, 2021 @12:41PM (#27039554)
Except in this specific example, OpenBSD doesn't have /proc
Re:CGI with Awk on OpenBSD Httpd (2020) by mrweasel on Tuesday May 04, 2021 @01:12PM (#27039896)
And it wouldn’t work in a chroot.
Re:CGI with Awk on OpenBSD Httpd (2020) by nwmcsween on Tuesday May 04, 2021 @03:12PM (#27041632)
This was an example... Do any command you feel like with that awk script
Re:CGI with Awk on OpenBSD Httpd (2020) by tyingq on Tuesday May 04, 2021 @09:18AM (#27037239)
You can also coax gawk into being a web server itself, albeit a bit brain-dead. I wish they would tweak the way it does server sockets so that you could make a decent forking server. As it stands now, you don't get the socket until after the listen() and accept().

https://news.ycombinator.com/item?id=22085459

Re:CGI with Awk on OpenBSD Httpd (2020) by mro_name on Wednesday May 05, 2021 @02:50AM (#27046933)
I like those tiny bits doing useful things. A lot.

E.g. dump form posts for later (offline) processing: https://codeberg.org/mro/form2xml/src/branch/master/dump.cgi

Re:CGI with Awk on OpenBSD Httpd (2020) by gbrown_ on Tuesday May 04, 2021 @09:29AM (#27037344)
I replied to someone on Twitter about this as I mistakenly thought they were the author, but the interpreter line in the example script should be #!/usr/bin/awk rather than #!/bin/awk.
Re:CGI with Awk on OpenBSD Httpd (2020) by the_trapper on Tuesday May 04, 2021 @10:03AM (#27037693)
The author actually has it right due to OpenBSD's httpd running in a chroot of /var/www.

Edit: nevermind, you're right, just checked it again and the author put the copied awk under /usr/bin inside the chroot

Re:CGI with Awk on OpenBSD Httpd (2020) by LeoPanthera on Tuesday May 04, 2021 @02:54PM (#27041376)
You can use "#!/usr/bin/env awk" to make it universal, this works on all the BSDs and Linux. Works for bash and other interpreters too.
Re:CGI with Awk on OpenBSD Httpd (2020) by gbrown_ on Tuesday May 04, 2021 @03:10PM (#27041602)
I just wanted to point out typo. I'm aware of the env idiom, though that wouldn't work in the chroot environment described in the article. Short of also copying it to the chroot which would be a bit redundant.
Re:CGI with Awk on OpenBSD Httpd (2020) by sigzero on Tuesday May 04, 2021 @12:38PM (#27039521)
Yeah, I don't see how to contact the actual author.
Re:CGI with Awk on OpenBSD Httpd (2020) by bifrost on Tuesday May 04, 2021 @03:42PM (#27041984)
I used to do this with csh to annoy a certain friend, awk would've been pretty good too TBH.
Re:CGI with Awk on OpenBSD Httpd (2020) by sigmonsays on Tuesday May 04, 2021 @03:09PM (#27041592)
totally unrelated to the topic but here I am following this blog now because of very much in common. That is, 1. i3, 2. emacs, 3. sync'ing git repos accross machines.

https://box.matto.nl/sparkleshare-to-sync-org-files.html

Re:CGI with Awk on OpenBSD Httpd (2020) by bdwjn on Tuesday May 04, 2021 @11:35AM (#27038714)
I was expecting computer-generated imagery, disappointed.