./ 000777 000000 000000 00000000000 02263252200 004652 ./isaacl1.txt 001777 000000 000000 00000017457 06533552316 006776 #!/bin/ksh ###################################################################### # Copyright (C) 1998 Steven G. Isaacson ###################################################################### # man.sh - web-enable man pages. This script should go in your web # server's $SERVER_ROOT/cgi-bin directory. # get a good awk AWK=awk whence gawk > /dev/null && AWK=gawk whence nawk > /dev/null && AWK=nawk tmpfile=/tmp/man.$$ tmpfile2=/tmp/man2.$$ ###################################################################### # standard html header stuff ###################################################################### echo "Content-type: text/html\n" ###################################################################### # parse the query string ###################################################################### # Use awk to split up the arguments, print them one per line in the # form of name="value", substitute + for space, and finally eval # everything. Another approach, instead of using eval, is to write the # entries to a file and then dot-in the file. # # Example. If "2 chown" is entered into the form, with no search # critera, then QUERY_STRING looks like this: # srch=&man=2+chown # # And the awk program below converts it to this: # srch="" # man="2 chown" eval $( if test "$REQUEST_METHOD" = POST then cat - else echo "$QUERY_STRING" fi | # tee /tmp/query.out | # debug for query string $AWK -F\& '{ for (i=1; i<=NF; i++) { x=$i gsub(/[^-_=+%a-zA-Z0-9]/, ".", x) # strip out any funny chars sub(/\=/, "='"'"'", x) # quote rhs in apostrophes sub(/$/, "'"'"'", x) gsub(/\+/, " ", x) # change + to space sub(/ /, "", x) if( x ~ /^(man|srch)=/ ) print x # only accept man=, srch= } }' # | tee /tmp/awk.out # debug for awk program ) #--------------------------------------------------------------------- escape() { #--------------------------------------------------------------------- # Escape characters for HTML output. sed -e 's,&$,__AMP__BR,g' \ -e 's,&,__AMP__,g' \ -e 's,<,__LT__,g' \ -e 's,>,__GT__,g' \ -e 's,__AMP__BR,\&,g' \ -e 's,__AMP__,\&,g' \ -e 's,__LT__,\<,g' \ -e 's,__GT__,\>,g' } #--------------------------------------------------------------------- display_form() #--------------------------------------------------------------------- { echo '
' } ###################################################################### # Start our HTML document ###################################################################### echo "" test -n "$man" || { echo "Error: no man request specified" display_form echo "