#!/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='
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 < 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.
You are not expected to understand this: your query string was
$QUERY_STRING, which this script was too incompetently written to parse
correctly. Send the author email
if this makes you unhappy. (He'll read it in his log anyway, so you
don't have to do this.)
$htmlend
eof
echo "`date` Screwup: $QUERY_STRING" >&3
;;
esac
eof
# ok, now we realize we should have used Perl.
IFS=,
while read name file primname junk; do :
case "$name" in
*"$searchterm"*)
if [ "x$name" = "x$primname" ] ; then
echo "