Simple Query Gateway


Here is the code for the finger CGI script. It outputs an ISINDEX query form when it is run without passing it any query arguments. Entering a search key in the form runs the script again; the query arguments that were entered are then passed to the UNIX finger command, and its output is returned.

#!/bin/sh

# Start with MIME-format message header:
echo "Content-type: text/html"
echo ""

# Check for query arguments:
if [ $# = 0 ]; then
	# No query, so send back a search index:
	cat << EOM
<TITLE>Finger Gateway</TITLE>
<H1>Finger Gateway</H1>
<ISINDEX>
This is a gateway to "finger".
Type a user@host combination in your
browser's search dialog.
EOM

else
	# Pass arguments to finger, output preformatted text:
	echo "<PRE>"
	finger "$*" 2>&1
fi

* Seminar Index |* Output-Only Gateway |* Forms Processing
Copyright (c) 1995, Gilbert Detillieux, Computer Science, University of Manitoba.