A Tcl cgi to display man pages in your browser
Here is a bit of tcl that I cobbled together to display man pages in my browser. Take the code and place into your cgi-bin directory and make it executable by the httpd process owner.
Jerry
#!/usr/bin/tclsh ################################################################ # A simple MAN page-WWW gateway # Hacker: Jerry LeVan # Environment: Linux 1.12; Perl 5.02 # Date: April 12, 1997 # # This code relys on the behavior of our man page program. When # called without a TERM, a bold ch is indicated by <ch><BS><ch>. # an underscored character is indicated by _<BS>ch. Your milage # may vary for other implementations. # # Rewritten for Tcl on Feb 4, 2011 yes it has been a while... # ################################################################# set env('MANPATH') "/usr/share/man:/usr/local/man:/usr/local/share/man:/usr/X11R6/man:/usr/man"; puts \ "Content-type: text/html <HTML><HEAD> <TITLE> WWW MAN PAGE </TITLE> <BASE TARGET=\"MANPAGE\"> </HEAD> <BODY BGCOLOR=#ffffff> <PRE>" # We don't have a query if called with no arguments if {! [string compare $env(QUERY_STRING) "" ] } { puts \ "<P ALIGN=CENTER> <FONT SIZE=5><B>WWW Man Page Tool</B></FONT></P> <ISINDEX> This is a gateway to the local man pages, type in a request and hit the return key. Do not use any quotes. Examples: <B>-k read</B> for a list of all man pages refering to <B>read</B>. <B>-a read</B> for all man pages for <B>read</B>. <B> 2 read</B> for the man page for <B>read</B> in chapter <B>2</B>. <B> read</B> for the first man page found for <B>read</B>. (Basically, whatever you type is appended to the <B><A href=/cgi-bin/man.tcl?man>man</a></B> command.) " } else { # We have a non-empty Query String... set target $env(QUERY_STRING) # As a security precaution we only decode + and : # replace the + signs in the url with blanks regsub -all {\+} $target " " target # for the perl users... regsub -all {%3A} $target {:} target if { [catch { set lines [eval [concat exec /usr/bin/man $target] ] } results]} { puts "Man page for \"$target\" not found.\n" puts "</PRE></BODY></HTML>\n" exit } regsub -all {(_\b(.)\b\2)} $lines {<U><B>\2</B></U>} lines regsub -all {_\b(.)} $lines {<U>\1</U>} lines ;# _bs ch -> <U>ch</U> regsub -all {((.)\b\2)} $lines {<B>\2</B>} lines ;# ch bs ch -> <B>ch</B> regsub -all {\+\bo} $lines {<B>o</B>} lines ;# + bs o -> <B>o</B> regsub -all {</B><B>} $lines {} lines ;# compress runs of </B><B> regsub -all {</U><U>} $lines {} lines ;# compress runs of </U><U> regsub -all {([^BU])>} $lines {\1\>} lines ;# Quote > if not preceeded by B or U regsub -all {<(?!(B|U|\/))} $lines {\<\1} lines ;# Quote < if not followed by B U or / puts $lines } puts "</PRE></BODY></HTML>\n"
Tain't perfect buts seems to do nicely on my Macs. Fedora does not appear to ship the man pages with formatting.