From saw@hallc1.cebaf.gov Wed Oct 20 16:03:21 1993 Date: Wed, 20 Oct 1993 03:32:44 GMT From: "Stephen A. Wood" Subject: WWW Linux man reader I hacked up a script I found that can make your linux man pages World Wide Web readable. You just need to add some lines to your /etc/services and /etc/inetd.conf files, and put the following script in /usr/local/htfiled (or whereever inetd.conf points.) Then from a WWW browser such as xmosaic, open the URL http://yourhostname:1235/man You do need to have networking up with at least loopback. This way of reading man pages puts in a link wherever a man page refers to another man page, so it is easy to jump around the man pages. I find it more pleasant than using xman. #!/bin/bash #bogus http server functions, directory browser, man page reader, etc. #install a service htfile in /etc/services and /etc/inetd.conf as follows: #services:htfile 1235/tcp #inetd.conf:htfile stream tcp nowait www /usr/local/htfiled htfiled #(Make sure you have a www dummy account). makewhatis must have been run so # that /usr/man/whatis exists and man -k works. # # To access, use the URL http://hostname:1235/man # # This file was modified by Stephen Wood (saw@cebaf.gov) from a ksh version for # IRIX 4.0 man pages. It's copyright status is unknown. exec 2>&1 #read get command line read get path #get rid of return character at end of get command ###path=`echo $path|sed s///` path=`echo $path|sed s/.$//` #parse arguments with / delimeter (this was a bad idea) dir="$path" cmd=`expr "$dir//" : '/\([^/]*\)/'` args=`expr "$dir" : '/[^/]*/\(.*\)'` dir=`expr "$dir" : '/[^/]*\(/.*\)'` arg=`expr "$dir//" : '/\([^/]*\)/'` dir=`expr "$dir" : '/[^/]*\(/.*\)'` arg2=`expr "$dir//" : '/\([^/]*\)/'` case $cmd in date) echo "Date and Time now

"`date`"

Wanna see it again? Here it is: "`date`".

" ;; man) if [ "$arg2" = "" ]; then pre="" else pre="../"; fi case "$arg" in "") echo "Linux Manual Pages

Linux Manual Pages

" echo "These are links to the Linux manual pages. You can" echo "look for information in several ways." echo "

" echo "
Keyword Search" echo "
where you can do a full text search for man pages" echo "that contain the keyword you specify." echo "
By section" echo "
where you can browse the names of the man pages" echo "in a section and choose items of interest." echo "
" exit ;; index*) ## I (saw) don't know what this ifs stuff does. It seems not to work without it though. ifs="$IFS" IFS="?$IFS" set $path dir=$1 if [ "$2" = "" ]; then echo "" echo "linux index" echo "

linux

" echo "Type a keyword to search for in the Linux man pages." else echo "Find Linux Manual $2

$2 Keyword search

" echo "
" ### The big substitute a few lines below (and repeated later), attempts to get ### the first command mentioned on the line, since there may be only a man page for ### that command and not the others (since they are all covered in one man page.) ### This seems to work with the set of Linux man pages I have. man -k $2|sed ' s/\&/\&/g s//\>/g s/^/
/ s/[ ]*- /
- / s/()// s|
([A-Za-z4][_A-Za-z0-9+]\{1,\})(.*)[ \t]*\(([1-9n][A-Za-z1-9]*)\)|
\1(\3)<\/A>\2|g s/$//' echo "
" fi exit ;; section*) ifs="$IFS" IFS="?$IFS" set $path dir=$1 if [ "$2" = "" ]; then echo "Man pages, by section, for Linux" echo "

Man pages, by section, for Linux

" echo "Choose a section of the linux manual from the list below:

" echo "Section 1 - Commands

" echo "Section 2 - System calls

" echo "Section 3 - Library calls

" echo "Section 4 - Devices

" echo "Section 5 - File formats

" echo "Section 6 - Games

" echo "Section 7 - Miscellaneous useful information

" echo "Section 8 - System Administration

" echo "Section n - New

" else echo "Linux man pages for section $2

Linux man pages for section $2

" echo "Select this to go back up to the section list for the Linux" echo "man pages, or choose a man page from the list below:

" cat /usr/man/whatis | grep \($2\) |sed ' s/\&/\&/g s//\>/g s/^/

/ s/[ ]*- /
- / s/()// s|
([A-Za-z4][_A-Za-z0-9+]\{1,\})(.*)[ \t]*\(([1-9n][A-Za-z1-9]*)\)|
\1(\3)<\/A>\2|g s/$//' echo "" fi exit ;; esac echo "Linux Manual Page: $arg $arg2

Linux $arg.$arg2

" echo "
"
##This sed replaces <'s, >'s and &'s with the right html directive.  It also
##searches for what appear to be man page references and puts in links to those pages.
        man $arg2 $arg|col -bx|sed '
s/\&/\&/g
s//\>/g
s|([A-Za-z4][_A-Za-z0-9+]\{1,\})[ \t]*\(([1-9n][A-Za-z1-9]*)\)|\1(\2)<\/A>|g
s/$//'
;;

*) echo unrecognized command. $cmd
;;

esac
exit
--

---------------------------------------------------------
Stephen A. Wood				       CEBAF/SURA
Internet: saw@hallc1.cebaf.gov		    Mail Stop 12H
Internet: saw@cebaf.gov            12000 Jefferson Avenue
Bitnet:   saw@cebaf                Newport News, VA 23606

Phone: (804)249-7367		Office: CEBAF Center C121
FAX:   (804)249-7363