#!/bin/ksh #tmp=/tmp/Ci.$$ #trap 'rm $tmp 2>/dev/null' 0 database=/home/eweb/botany/public_html/cp/data/jans.db pgrep=/home/eweb/botany/bin/pgrep awk=awk accepted=0 cultivar=0 while [ $# -gt 0 ] ; do case $1 in -C ) cultivar=1; shift ;; -A ) accepted=1; shift ;; * ) break ;; -* ) echo "$0: script error: option $1 is not handled" 1>&2; exit esac done # Now only pattern is left pat=$* pwd=`pwd` # if the -A flag is given then adjust pattern search to # only allow accepted name entries. # if [ $accepted = 1 ] then pat="[NFG]:.\%2b.*$pat" fi # if the -C flag is given then adjust pattern search to # only allow cultivar name entries. # if [ $cultivar = 1 ] then pat="[NFG]:.\%24.*$pat" fi #echo "pattern = $pat" #echo "pwd = $pwd" ############################################################## # The old nawk-based system version of pgrep: # pgrep -i $pat < $database | nawk ' # is replaced by a custom program that runs ~10x faster # The "-u" option treats the pattern as URL encoded ############################################################## if [ $accepted = 1 ] then echo "
" } intext++ xyz = $0 sub("^\+[ ]*","",xyz) print xyz next; } // { print "in //" # ignore anything not explicitly matched next; } END { print "in END" if (matches == 0) { print "No matches found!
" if ( '$accepted' == 1) { print "If you are searching for something other than" print "an accepted plant name, (eg: author, location, date," print " etc.), then you might want to try using the" print "\"show all matching entries\" option." print "This option will allow your search string" print "to match any field in the database rather" print "than just the plant name field.
" } else if ( '$cultivar' == 1) { print "If you are searching for something other than" print "a cultivar name, (eg: the author, location," print "date, etc.), then you might want to try using the" print "\"show all matching entries\" option." print "This option will allow your search string" print "to match any field in the database rather" print "than just the plant name field.
" } else { print "Your search string does not match anything in" print "the Carnivorous Plant Database. Perhaps you are" print "misspelling your query. You might try a shorter" print "abbreviation of your word, or a different spelling." print "If you still have trouble, then perhaps you might" print "try reading about how" print "search patterns work." } } } '