HowTos/Convert Man Pages

From Scalix Wiki
Jump to: navigation, search

Scalix Wiki -> How-Tos -> Convert Scalix Man Pages to pdf and html


This script will get the man pages into html and a pdf document.

#!/bin/sh 

# scalix man page convertion. 
sourcedir="/opt/scalix/share/man/" 
exportpath="/path_to/Scalix_man_pages/" 
exportdir="html" 
rm -f $exportpath$exportdir/index.html 
touch $exportpath$exportdir/index.html 
echo "<html><title>Scalix Man pages</title><body><table>" >> $exportpath$exportdir/index.html 

cd $sourcedir 
for MANFOLDERS in `ls -1` 
do 
   cd $sourcedir$MANFOLDERS 
   for MANPAGES in `ls -1` 
   do 
      filename=`echo "${MANPAGES}" | sed "s/.gz*$//" | sed "s/\..$//"` 
      detail=`gunzip -dc $MANPAGES |grep -A1 NAME|cut -d$'\n' -f2`
      filename2=`echo "${MANPAGES}" | sed "s/.gz*$//"` 
      hyperlink="<tr><td valign=top><a href='$filename2.html'>$filename</a></td><td>$detail <br></td></tr>" 
      echo $hyperlink >> $exportpath$exportdir/index.html 
      gzip -dc $sourcedir/$MANFOLDERS/$MANPAGES | man2html -r | sed -e "s/man./$exportdir/g" |  sed -e "s@index.html@$exportdir/index.html@g" | sed -n -e :a -e '1,6!{P;N;D;};N;ba' > $exportpath$exportdir/$filename2.html 2>&1
      echo "</body></html>">>$exportpath$exportdir/$filename2.html 
      echo $MANPAGES " - " $filename " - converted" 
   done 
done 
echo "</table></body></html>" >> $exportpath$exportdir/index.html 
htmldoc --continuous -f $exportpath$exportdir/Scalix_Man_Pages.pdf $exportpath$exportdir/*.html 

htmldoc can be downloaded from here for redhat: http://rpm.pbone.net/

"A collection of converted man pages to html. Also a PDF version. From server version: 11.0.3.31" http://dl.dropbox.com/u/7856668/scalix/scalix_man_pages.zip