#!/bin/sh
# USAGE: 
#        htmconv <filename> 
#   Where <filename> is the source file (or files) to be updated.
#  
# EXAMPLES:
#	htmconv ch1.htm
#	htmconv ch1.htm ch5.htm apa.htm
#	htmconv server.813/a63840/*.htm
#
# NOTES:
#   Before running this script, you must set the HTMCONV_HOME environment
#   variable.  This is the working directory where temporary files are
#   created (and later removed).
#   

#check arguments
if  [ $# -eq 0 ] 
then
  echo "Usage: htmconv <filename1> [<filename2>] ... [<filenamen>]"
  echo ""
  echo "Note that <filename> is read AND CHANGED!" 
  echo ""
  exit
fi

#Now for each file passed as an argument...
for i in $* 
do 
  echo Converting file....$i
  echo "<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN"> <html> <pre>" > tempfile
  cat $i >> tempfile
  echo "</pre> </html>" >> tempfile
  cat tempfile > $i

done
rm tempfile
