'''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 . # an underscored character is indicated by _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 WWW MAN PAGE
"
# We don't have a query if called with no arguments
if {! [string compare $env(QUERY_STRING) "" ] } { 
  puts \
  "

WWW Man Page Tool

This is a gateway to the local man pages, type in a request and hit the return key. Do not use any quotes. Examples: -k read for a list of all man pages refering to read. -a read for all man pages for read. 2 read for the man page for read in chapter 2. read for the first man page found for read. (Basically, whatever you type is appended to the man 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 "
\n" exit } regsub -all {(_\b(.)\b\2)} $lines {\2} lines regsub -all {_\b(.)} $lines {\1} lines ;# _bs ch -> ch regsub -all {((.)\b\2)} $lines {\2} lines ;# ch bs ch -> ch regsub -all {\+\bo} $lines {o} lines ;# + bs o -> o regsub -all {} $lines {} lines ;# compress runs of regsub -all {} $lines {} lines ;# compress runs of 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 "\n" ====== Tain't perfect buts seems to do nicely on my Macs. Fedora does not appear to ship the man pages with formatting. <>Uncategorized