#!/bin/sh # server for New Context Matcher # arguments are X co-ord (up to 7 digits), Y co-ord (up to 7 digits), threhold (optional) WEBPAGES="~www/docs/academics/pjbrown/public_html" WEBPAGES="/home/pjbrown/public_html" PATH=.:/home/pjbrown/bin:/usr/java/bin:/usr/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/jdk/bin:/usr/X11R6/bin:/usr/local/jdk/bin:$PATH echo "Content-type: text/plain" echo # really we should use QUERY_STRING; see mtr's mail echo "" # check arguments if test ! -n "$1"; then echo "ERROR: null X-cordinate (first argument)" exit fi if test ! -n "$2"; then echo "ERROR: null Y-cordinate (second argument)" exit fi THRESHOLD=$3 if test ! -n "$3"; then THRESHOLD=1.9 fi # this is a magic command that redirects all subsequent errors to stdout exec 2>&1 # do URL decodings # actually the conversion below have already been done X=`echo "$1" | sed "$SED_COMMANDS s/%20/ /g s/%2C/,/g s/%2c/,/g s/%2F/\//g s/%2f/\//g s/%3B/;/g s/%3b/;/g # for some reason %3B seems to become \; BUT the s/\\;/ still does not work, so we delete ANTHING before ';' # PS is the reason: all URL-encoded characters get \ put before them? #s/\\;/;/g s/.;/;/g # ... and similarly for < and > and ~ s/./>/g s/.~/~/g # s/%3D/=/g s/&/ /g "` # actually the conversion below have already been done Y=`echo "$2" | sed "$SED_COMMANDS s/%20/ /g s/%2C/,/g s/%2c/,/g s/%2F/\//g s/%2f/\//g s/%3B/;/g s/%3b/;/g # for some reason %3B seems to become \; BUT the s/\\;/ still does not work, so we delete ANTHING before ';' # PS is the reason: all URL-encoded characters get \ put before them? #s/\\;/;/g s/.;/;/g # ... and similarly for < and > s/./>/g s/.?/?/g # s/%3D/=/g s/%3d/=/g s/&/ /g "` if test ! -z "$4"; then echo "" fi echo "" # WAS: use -p and -P (thus assume old notation) #echo '' # convert args to 7 digits ARG1=`echo $X | /usr/bin/awk '{str=$1 "000000"; print substr(str, 0, 7)}'` ARG2=`echo $Y | /usr/bin/awk '{str=$1 "000000"; print substr(str, 0, 7)}'` cd /home/pjbrown/tmp/CAR_share_copy/Xamples ./run_sw "$ARG1,$ARG2" "$THRESHOLD" | /home/pjbrown/tourist_database/sort_notes - | head -30 #echo ""