#!/bin/sh # # Simple CGI program to search the directory of people I know. Parses # query string; if no query string, prints out a search form, otherwise # runs a search or gives an error. Either way, logs all responses in # /home/kragen/querylog. # # Boy, it's fun to write CGI scripts in sh. Not. :) # "It seemed like a good idea at the time." # The problem is, of course, sh makes it hard to do interesting # processing. Properly decoding the QUERY_STRING is beyond its # capacities. # # Of course, it's also not the highest-performance programming # environment in existence, and it's prone to severe security bugs, # which I have carefully avoided here. I think. # dir="/home/kragen/public_html/pik/dir.txt" log="/home/kragen/querylog" htmlhead=' ' htmltobody='' htmlend='

Index of people|email Kragen|Kragen'\''s home page ' exec 3>>"$log" echo "`date` running" >&3 echo "Content-type: text/html" echo "" case "X$QUERY_STRING" in X) cat <Search form for people Kragen knows

Enter some fragment of the name of the person you're looking for. If you're entering both a first and last name, enter the first name first: Kragen Sittler.

$htmlend eof echo "`date` Served form" >&3 ;; # talk about kludgy query-string decoding! Xq=*) searchterm="`echo "$QUERY_STRING" | dd bs=1 skip=2 | sed 's/+/ /g'`" cat <"$searchterm": Search results for people Kragen knows