home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / system / manual_p / linuxman.sh / text0000.txt < prev   
Encoding:
Text File  |  1993-10-21  |  5.8 KB  |  160 lines

  1. I hacked up a script I found that can make your linux man pages World
  2. Wide Web readable.  You just need to add some lines to your /etc/services
  3. and /etc/inetd.conf files, and put the following script in
  4. /usr/local/htfiled (or whereever inetd.conf points.)  Then from a WWW
  5. browser such as xmosaic, open the URL http://yourhostname:1235/man
  6. You do need to have networking up with at least  loopback.
  7.  
  8. This way of reading man pages puts in a link wherever a man page refers to
  9. another man page, so it is easy to jump around the man pages.  I find it
  10. more pleasant than using xman.
  11.  
  12. #!/bin/bash
  13. #bogus http server functions, directory browser, man page reader, etc.
  14. #install a service htfile in /etc/services and /etc/inetd.conf as follows:
  15. #services:htfile                1235/tcp                
  16. #inetd.conf:htfile stream tcp nowait www /usr/local/htfiled htfiled
  17. #(Make sure you have a www dummy account).  makewhatis must  have been run so
  18. # that /usr/man/whatis exists and man -k works.
  19. #
  20. # To access, use the URL http://hostname:1235/man
  21. #
  22. # This file was modified by Stephen Wood (saw@cebaf.gov) from a ksh version for
  23. # IRIX 4.0 man pages.  It's copyright status is unknown.
  24. exec 2>&1
  25.  
  26. #read get command line
  27. read get path
  28.  
  29. #get rid of return character at end of get command
  30. ###path=`echo $path|sed s///`
  31. path=`echo $path|sed s/.$//`
  32.  
  33. #parse arguments with / delimeter (this was a bad idea)
  34. dir="$path"
  35. cmd=`expr "$dir//" : '/\([^/]*\)/'`
  36. args=`expr "$dir" : '/[^/]*/\(.*\)'`
  37. dir=`expr "$dir" : '/[^/]*\(/.*\)'`
  38. arg=`expr "$dir//" : '/\([^/]*\)/'`
  39. dir=`expr "$dir" : '/[^/]*\(/.*\)'`
  40. arg2=`expr "$dir//" : '/\([^/]*\)/'`
  41.  
  42. case $cmd in
  43.  
  44. date) echo "<TITLE>Date and Time now</TITLE><H1>"`date`"</H1>Wanna see it again?  Here it is: "`date`".<P>"
  45. ;;
  46.  
  47. man) 
  48.         if [ "$arg2" = "" ]; then pre=""
  49.         else pre="../"; fi
  50.         case "$arg" in
  51.         "")
  52.         echo "<TITLE>Linux Manual Pages</TITLE><H1>Linux Manual Pages</H1>"
  53.         echo "These are links to the Linux manual pages.  You can"
  54.         echo "look for information in several ways."
  55.         echo "<p><dl>"
  56.         echo "<dt><a name=id1 href=man/index>Keyword Search</a>"
  57.         echo "<dd>where you can do a full text search for man pages"
  58.         echo "that contain the keyword you specify."
  59.         echo "<dt><a name=id2 href=man/section>By section</a>"
  60.         echo "<dd>where you can browse the names of the man pages"
  61.         echo "in a section and choose items of interest."
  62.         echo "</dl>"
  63.         exit
  64.         ;;
  65.         index*)
  66. ## I (saw) don't know what this ifs stuff does.  It seems not to work without it though.
  67.         ifs="$IFS"
  68.             IFS="?$IFS"
  69.             set $path
  70.         dir=$1
  71.         if [ "$2" = "" ]; then
  72.                 echo "<ISINDEX>"
  73.                 echo "<title>linux index</title>"
  74.                 echo "<h1>linux</h1>"
  75.         echo "Type a keyword to search for in the Linux man pages."
  76.         else
  77.                 echo "<TITLE>Find Linux Manual $2</TITLE><H1>$2 Keyword search</H1>"
  78.                 echo "<DL>"
  79. ### The big substitute a few lines below (and repeated later), attempts to get
  80. ### the first command mentioned on the line, since there may be only a man page for
  81. ### that command and not the others (since they are all covered in one man page.)
  82. ### This seems to work with the set of Linux man pages I have.
  83.                 man -k $2|sed '
  84. s/\&/\&/g
  85. s/</\</g
  86. s/>/\>/g
  87. s/^/<DT>/
  88. s/[      ]*- /<DD>- /
  89. s/()//
  90. s|<DT>([A-Za-z4][_A-Za-z0-9+]\{1,\})(.*)[ \t]*\(([1-9n][A-Za-z1-9]*)\)|<DT><A HREF=\1\/\3>\1(\3)<\/A>\2|g
  91. s/$//'
  92.                 echo "</DL>"
  93.         fi
  94.         exit
  95.             ;;
  96.         section*)
  97.         ifs="$IFS"
  98.         IFS="?$IFS"
  99.         set $path
  100.         dir=$1
  101.         if [ "$2" = "" ]; then
  102.             echo "<title>Man pages, by section, for Linux</title>"
  103.             echo "<h1>Man pages, by section, for Linux</h1>"
  104.             echo "Choose a section of the linux manual from the list below:<p>"
  105.                 echo "Section <a href=section?1>1</a> - Commands<p>"
  106.                 echo "Section <a href=section?2>2</a> - System calls<p>"
  107.                 echo "Section <a href=section?3>3</a> - Library calls<p>"
  108.                 echo "Section <a href=section?4>4</a> - Devices<p>"
  109.                 echo "Section <a href=section?5>5</a> - File formats<p>"
  110.                 echo "Section <a href=section?6>6</a> - Games<p>"
  111.                 echo "Section <a href=section?7>7</a> - Miscellaneous useful information<p>"
  112.                 echo "Section <a href=section?8>8</a> - System Administration<p>"
  113.                 echo "Section <a href=section?n>n</a> - New<p>"
  114.         else
  115.         echo "<title>Linux man pages for section $2</title><h1>Linux man pages for section $2</h1>"
  116.         echo "Select this to go back up to the section list for the Linux"
  117.         echo "man pages, or choose a man page from the list below:<p>"
  118.         cat /usr/man/whatis | grep \($2\) |sed '
  119. s/\&/\&/g
  120. s/</\</g
  121. s/>/\>/g
  122. s/^/<DT>/
  123. s/[      ]*- /<DD>- /
  124. s/()//
  125. s|<DT>([A-Za-z4][_A-Za-z0-9+]\{1,\})(.*)[ \t]*\(([1-9n][A-Za-z1-9]*)\)|<DT><A HREF=\1\/\3>\1(\3)<\/A>\2|g
  126. s/$//'
  127.                 echo "</DL>"
  128.         fi
  129.         exit
  130.         ;;
  131.         esac
  132.         echo "<TITLE>Linux Manual Page: $arg $arg2</TITLE><H1>Linux $arg.$arg2</H1>"
  133.         echo "<PRE>"
  134. ##This sed replaces <'s, >'s and &'s with the right html directive.  It also
  135. ##searches for what appear to be man page references and puts in links to those pages.
  136.         man $arg2 $arg|col -bx|sed '
  137. s/\&/\&/g
  138. s/</\</g
  139. s/>/\>/g
  140. s|([A-Za-z4][_A-Za-z0-9+]\{1,\})[ \t]*\(([1-9n][A-Za-z1-9]*)\)|<A HREF='$pre'\1\/\2>\1(\2)<\/A>|g
  141. s/$//'
  142. ;;
  143.  
  144. *) echo unrecognized command. $cmd
  145. ;;
  146.  
  147. esac
  148. exit
  149. --
  150.  
  151. ---------------------------------------------------------
  152. Stephen A. Wood                       CEBAF/SURA
  153. Internet: saw@hallc1.cebaf.gov            Mail Stop 12H
  154. Internet: saw@cebaf.gov            12000 Jefferson Avenue
  155. Bitnet:   saw@cebaf                Newport News, VA 23606
  156.  
  157. Phone: (804)249-7367        Office: CEBAF Center C121
  158. FAX:   (804)249-7363
  159.  
  160.