eddyg@cogs.sussex.ac.uk ("Edward J. Groenendaal") (08/30/90)
Returning to the earlier question about rebuilding the whatis database, I got fed up with doing it by hand and so wrote a 'short' csh script to do it automatically, it's not very clever, but works most of the time. I've included it at the end of this message. I've also got a comment to make about the prices of of Apple machines in England... The cost of my Apple IIcx with just over 25% educational discount came to about 4000 pounds, with the exchange rate as it is that comes to about $8000 which sounds a bit bloody stupid to me. It's cheaper to fly to the USA buy the machine their have a few weeks holiday then pay the import tax on the way back to England!!! The only reason I mention it now is that I've just had to pay the interest on the loan for the machine, which as you can imagine with the interest rates as they are at the moment was MASSIVE. Could somebody at Apple please explain why the machines in England have to be twice the cost of those in the USA, especially since the average income in England is much less than that in the USA. Anyway here's the shell script. Edward. PS. I've only tested this under A/UX 1.1 (I missed A/UX 2 by a month and can't afford the upgrade....) ---- Cut Here ---- #!/bin/csh # ----------------------------------------------------------------------------- # Csh script to add manual page entries to the whatis database. # It will automatically unpack/compress/compact the file, # extract the whatis info from it and add it to a temporary whatis database. # The finished database is left sorted in /tmp/whatis, for use it will have # to be copied to /usr/lib/whatis (replacing the old one) # # Author : Edward Groenendaal <eddyg@cogs.sussex.ac.uk> # Date : 29th August 1990 # # Usage : rewhatis [ files ] # # Note : This script was hacked together in a couple of hours, it's no # where near perfect, in fact it's a mess... but works! # # ----------------------------------------------------------------------------- unset noclobber set filenames=($*) set tmpfile="/tmp/rw$$" set tmpmanpage="/tmp/tm$$" set mywhatis="/tmp/what$$" set whatis="/usr/lib/whatis" set BS=`/bin/echo "\b\c"` #set up new whatis database. cp $whatis $mywhatis echo "Adding the following manual pages to the whatis database" foreach filename ($filenames) set manpage=`echo $filename | sed "s/.Z//g;s/.z//g;s/.C//g"` set res=`whatis $manpage` if ("$res[2]" == "not") then switch ("$filename") case "*.Z": # The manpage is compressed zcat $filename > $tmpfile breaksw case "*.z": # The manpage is packed pcat $filename > $tmpfile breaksw case "*.C": # The manpage is compacted ccat %filename > $tmpfile breaksw default: # Assume it's not compressed or packed cp $filename $tmpfile breaksw endsw if ("`file $tmpfile | cut -d' ' -f2`" == "tbl,") then nroff -man $tmpfile > $tmpmanpage /bin/rm -f $tmpfile else mv $tmpfile $tmpmanpage endif # The file is plain text # Find the line where the info starts set line=`grep -n '-' $tmpmanpage | head -2 | cut -d':' -f1,3` if ($line[1] < 8) then set line=`expr $line[2] + 1` # In case of '-' in title else set line=`expr $line[1] + 1` endif set wtext=`head -$line $tmpmanpage | tail -2 ` set names=`echo $wtext | cut -d'-' -f1 | sed 's/,//g'` set text=`echo $wtext | cut -d'-' -f2` set namestr=`head -4 $tmpmanpage | tail -1 | sed "s/.$BS//g"` # A quick hack because of some funny characters in X man pages. if (`echo $namestr[1] | wc -c` < 4) then set name="$names("`expr $namestr[2] : '.*(\(.*\))'`")" else set name="$names("`expr $namestr[1] : '.*(\(.*\))'`")" endif if (`echo $name | wc -c` < 25) then # Pad out name with spaces until it's 25 chrs long. # Messy but who cares... :-) echo \ "`expr '$name ' : '^\(.........................\)'`-"\ "$text" | tee -a $mywhatis else echo "$name - $text" | tee -a $mywhatis endif /bin/rm -f $tmpmanpage endif # Is already in whatis database. end sort $mywhatis > /tmp/whatis /bin/rm -f $mywhatis echo "The new whatis database is in /tmp/whatis, move this file" echo "to /usr/lib/whatis"
einhorn@hydra.unm.edu (E Drew Einhorn ADV.SCI.Inc) (08/30/90)
In article <11014.9008301102@tsuna.cogs.susx.ac.uk> eddyg@cogs.sussex.ac.uk ("Edward J. Groenendaal") writes: >Returning to the earlier question about rebuilding the whatis >database, I got fed up with doing it by hand and so wrote a 'short' >csh script to do it automatically, it's not very clever, but works >most of the time. I've included it at the end of this message. > On some other systems the command: catman -w rebuilds the whatis database Unfortuneatley I only have an executable on my Sparcstation. But maybe somebody can find the source for a version that works all the time. -- einhorn@hydra.unm.edu
morrell@hpcuhb.HP.COM (Michael Morrell) (08/31/90)
/comp.unix.aux/einhorn@hydra.unm.edu (E Drew Einhorn)/9:16 am Aug 30, 1990 In article <11014.9008301102@tsuna.cogs.susx.ac.uk> eddyg@cogs.sussex.ac.uk ("Edward J. Groenendaal") writes: >Returning to the earlier question about rebuilding the whatis >database, I got fed up with doing it by hand and so wrote a 'short' >csh script to do it automatically On some other systems the command: catman -w rebuilds the whatis database ---------- And on others, you can use "/usr/lib/mkwhatis". Michael