#!/bin/sh # Man-cgi : a Common Gateway Interface which converts the output of # the "man" command to HTML # VERSION="1.15S" # Local, Solaris version by David Adams # # Author : Panagiotis J. Christias # # Usage : it goes in the /cgi-bin/ directory. When called without # arguments (http://www-server/cgi-bin/man-cgi) it outputs a # "Front Page" with a section list and query form. When called # with arguments, the first argument is the topic (e.g. ls) # and the second argument (optional) is the section to look in. # # Examples: # http://www.ntua.gr/cgi-bin/man-cgi?ls # http://www.ntua.gr/cgi-bin/man-cgi?sleep+3 # # Notice : Man-cgi uses the following two images, you may want to get them # and put them in your w3 server: # http://www.ntua.gr/images/doty.gif # http://www.ntua.gr/images/pages.gif # # History : # 1.15 Multiple blank lines are supressed. # 1.14 Man-cgi now recognizes cross-references that # contain periods (e.g. foo.foo(3)). # 1.13 Really fixed problems occuring in pages which used # multi-overstrike for emboldening (hopefully). # 1.12 Fixed problems occuring in pages which used multi-overstrike # for emboldening. Now Man-cgi works any number of overstrike. # 1.11 Fixed problem with hyphenated cross-references. # 1.10 and earlier, no history at that time... # # Last update: Fri May 5 1995 # Fri June 2 1995 David Adams ### CONFIGURATION SECTION : change the following variables to fit your needs ### # The HTTPD server may not pass the environment variables to the script. # You should add your system path here : PATH=/usr/bin:/usr/local/bin:/opt/sfw/bin export PATH # The same for the man path here : MANPATH=/usr/local/man:/usr/man:/opt/sfw/man manpath_ext1=/fs1/local/SUNWspro/man name_ext1="SUNWspro" manpath_ext2=/local/uniras/6v3b/man name_ext2="UNIRAS 6v3b" manpath_ext3=/local/gino/man name_ext3="GINO 4.0a" manpath_ext4=/local/motif/man name_ext4="Motif 1.2.1e" # The full URL of the Man-cgi : MANCGI='http://cis.kutztown.edu/~frye/cgi-bin/unixManPages.cgi' # The URL of the two images : DOT=http://cis.kutztown.edu/~frye/images/doty.gif PAGES=http://cis.kutztown.edu/~frye/images/pages.gif ### END OF CONFIGURATION SECTION ############################################### SECTION=$2 COMMAND=$1 EXT1=`echo $3 | fgrep "1"` EXT2=`echo $3 | fgrep "2"` EXT3=`echo $3 | fgrep "3"` EXT4=`echo $3 | fgrep "4"` echo "Content-type: text/html" echo "" if [ $# -eq 2 ] ; then if [ $2 = "00" ] ; then read a a=`echo $a | sed -e 's/%2[cC]/\,/g' -e 's/ //' -e 's/\(.*\)$/\1&\'` COMMAND=`echo $a | sed -e 's/^command=//' \ -e 's/&.*$//'` SECTION=`echo $a | sed -e 's/^.*§ion=//' \ -e 's/&.*$//'` EXT1=`echo $a | fgrep '&EXT1'` EXT2=`echo $a | fgrep '&EXT2'` EXT3=`echo $a | fgrep '&EXT3'` EXT4=`echo $a | fgrep '&EXT4'` fi; fi; if [ "$SECTION" = "ANY" ] ; then SECTION="" fi; EXTRA="" if [ -n "$EXT1" ] ; then MANPATH=${manpath_ext1}:${MANPATH} EXTRA=${EXTRA}1 fi; if [ -n "$EXT2" ] ; then MANPATH=${manpath_ext2}:${MANPATH} EXTRA=${EXTRA}2 fi; if [ -n "$EXT3" ] ; then MANPATH=${manpath_ext3}:${MANPATH} EXTRA=${EXTRA}3 fi; if [ -n "$EXT4" ] ; then MANPATH=${manpath_ext4}:${MANPATH} EXTRA=${EXTRA}4 fi; export MANPATH if [ -n "$EXTRA" ] ; then EXTRA="+${EXTRA}" fi; if [ $# -ne 0 ] ; then cat < UNIX man pages : $COMMAND ($SECTION) END if [ "$SECTION" = "KEY" ] ; then cat <Search on the Keyword: "${COMMAND}"
END man -k $COMMAND 2> /dev/null | \ sed \ -e 's//»/g' \ -e 's/\&/§/g' \ -e "s#\(\([0-9A-z][-.,0-9A-z]*\) (\([1-9][A-z]*\))\)#\1#g" \ \ -e 's/§/\&/g' \ -e 's/«/\</g' \ -e 's/»/\>/g' | \ awk 'BEGIN { print "
" }
     /^$/     { if(!blank) { print; blank=1 } }
     /^..*$/  { print; blank=0 }
     END   { print "
" }' else if [ -n "$SECTION" ] ; then SECTION="-s $SECTION" fi; man $SECTION $COMMAND 2> /dev/null | \ sed \ -e '/-$/N { s/\([0-9A-z][-,0-9A-z]*\)-\n\( *\)\([0-9A-z][-,0-9A-z]*([1-9][A-z]*)\)/\1\3\ \2/ }' \ -e '/-$/N { s/\([0-9A-z][-,0-9A-z]*\)-\n\( *\)\([0-9A-z][-,0-9A-z]*([1-9][A-z]*)\)/\1\3\ \2/ }' \ -e '/-$/N { s/\([0-9A-z][-,0-9A-z]*\)-\n\( *\)\([0-9A-z][-,0-9A-z]*([1-9][A-z]*)\)/\1\3\ \2/ }' \ -e '/-$/N { s/\([0-9A-z][-,0-9A-z]*\)-\n\( *\)\([0-9A-z][-,0-9A-z]*([1-9][A-z]*)\)/\1\3\ \2/ }' \ -e 's//»/g' \ -e 's/\&/§/g' \ \ -e '/^[A-Z]/s/.//g' \ -e 's/^[A-Z][- ,A-Z]*$/

&<\/H2>/' \ \ -e 's/\([^_]\)\([^\1]\)/\2/g' \ -e 's/_|/|/g' \ -e 's/\(.\)\1/\1/g' \ -e 's/_\(.\)\1/\1<\/i><\/b>/g' \ -e 's/_\(.\)/\1<\/cite>/g' \ -e 's/.\(.\)/\1<\/b>/g' \ \ -e 's#.##g' \ -e 's#.##g' \ -e 's#.##g' \ \ -e 's/<\/cite>//g' \ -e 's/<\/b>//g' \ -e 's/<\/i>//g' \ -e 's/<\/i><\/b>//g' \ \ -e 's/^ \([A-Z][ ,0-9A-z]*\)$/ \1<\/b>/' \ -e 's/^ \([A-Z][ ,0-9A-z]*\)$/ \1<\/b>/' \ \ -e "/^ /s#\(\([0-9A-z][-.,0-9A-z]*\)(\([1-9][A-z]*\))\)#\1#g" \ -e "/^ /s#\(\([0-9A-z][-.,0-9A-z]*\)(\([1-9][A-z]\)*)\)#\1#g" \ \ -e "s#+<\/b>##" \ \ -e 's/§/\&/g' \ -e 's/«/\</g' \ -e 's/»/\>/g' | \ awk 'BEGIN { print "
" }
     /^$/     { if(!blank) { print; blank=1 } }
     /^..*$/  { print; blank=0 }
     END   { print "
" ; if( NR < 5) \ { print "
"; \ printf("NOTE: man page for %s may be in the wrong place.\n",PAGE); \ printf("Try all sections and all optional pages\n",URL,PAGE); } }' \ PAGE=$COMMAND URL=$MANCGI fi; cat <

Solaris Man Pages

END else cat < UNIX man pages

UNIX ON-LINE Man Pages


These are the UNIX man pages for the Solaris service, converted to html on the fly by a shell script.

Here are the intro pages of each section:


You can also request a man page by name and (optionally) by section,
or perform a keyword search:

Set command name :

Select section number or keyword search:

Optional extra pages:
${name_ext1}
${name_ext2}
${name_ext3}
${name_ext4}

END fi cat <
© 1994 Man-cgi $VERSION, Panagiotis Christias <christia@theseas.ntua.gr>
1995 Modified for Solaris 2.3, David Adams, <d.j.adams@soton.ac.uk>
END