home *** CD-ROM | disk | FTP | other *** search
/ HTML - Publishing on the Internet / html_cdrom.iso / tools / html / windows / check / runpchek.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  1995-02-19  |  4KB  |  115 lines

  1. #!/bin/sh
  2. #
  3. # Shell script to run HTML cross-reference checking with htmlchek.pl
  4. #
  5. case ${HTMLCHEK:-"/"}
  6.     in */ );;
  7.        * ) HTMLCHEK="$HTMLCHEK/";;
  8. esac
  9. if test $# -lt 2
  10. then
  11.     echo "
  12.  Syntax is:  $0 directoryprefix outfileprefix [directory] [options]
  13. " >&2
  14. cat >&2 << '_EOHERE_'
  15.  The optional third parameter specifies the top directory of the tree in which
  16. all .html files are to be checked (for example, "$HOME/public_html"); if this
  17. is not present, then the current directory is used.  The first parameter
  18. ``directoryprefix'' is how this top directory is referenced in <...HREF="...">
  19. links in files in subordinate directories in the tree (for example, as
  20. "/~myself/" or "http://myhost.edu/~myself/").  If the files you are checking
  21. refer to each other only with simple relative URL's (i.e. with no access
  22. method or hostname specified, and not beginning with `/'), then you can get
  23. away with specifying ``directoryprefix'' as a null string ('').
  24.  
  25.  The second parameter ``outfileprefix'' is the name of the files (with the
  26. extensions ".NAME", ".HREF", ".SRC", and ".ERR") in which the ouput of the
  27. HTML-checking and cross-referencing process will be put.  And finally, the
  28. optional parameters are all of the form "option=value", as explained in the
  29. docs.  So the following are some typical command lines (putting
  30. _EOHERE_
  31.  echo "$0 first in a command, as in the first example, implies that
  32. you have set execute permission by running \"chmod +x $0\"):
  33.  
  34.   $0  http://uts.cc.utexas.edu/~churchh/  check
  35.  
  36.   sh  $0  ''  out  \$HOME/public_html  html3=1" >&2
  37.     exit 1
  38. else
  39.     if test -s ${HTMLCHEK}htmlchek.pl
  40.     then
  41.      case $1
  42.      in *?=* ) echo "Error: dirprefix parameter  $1  is in option=value form" >&2
  43.                exit 1;;
  44.      esac
  45.      case $2
  46.      in *?=* ) echo "Error: outfilesname parameter  $2  is in option=value form" >&2
  47.                exit 1;;
  48.      esac
  49.     dprefix=$1
  50.     oprefix=$2
  51.     shift 2
  52.     if test $# -ge 1
  53.     then
  54.         case $1
  55.              in *=* ) targdir='';;
  56.                   * ) targdir=$1
  57.                       shift;;
  58.         esac
  59.     else
  60.         targdir=''
  61.     fi
  62.     case ${dprefix:-"/"}
  63.         in */ ) ;;
  64.             * ) dprefix="$dprefix/";;
  65.     esac
  66.     case $dprefix
  67.          in ?* ) dprefix="dirprefix=$dprefix";;
  68.              * ) ;;
  69.     esac
  70.     case $targdir
  71.         in */ ) echo "Error: Target directory name  $targdir  should not have trailing slash" >&2
  72.                 exit 1;;
  73.            ?* ) subopt="subtract=${targdir}/";;
  74.             * ) subopt='';;
  75.     esac
  76.     for px
  77.     do
  78.     case $px
  79.     in append=* | arena=* | cf=* | configfile=* | deprecated=* |\
  80.     dlstrict=* | html3=* | htmlplus=* | loosepair=* |\
  81.     lowlevelnonpair=* | lowlevelpair=* | map=* | metachar=* |\
  82.     netscape=* | nogtwarn=* | nonblock=* | nonpair=* |\
  83.     nonrecurpair=* | novalopts=* | nowswarn=* | reqopts=* |\
  84.     strictpair=* | sugar=* | tagopts=* | usebase=* ) ;;
  85.        * ) echo "Error: The argument  $px  is not in option=value form, where," >&2
  86.            echo "the part before the equals sign \`=' is a recognized option." >&2
  87.            exit 1;;
  88.     esac
  89.     done
  90.     echo "Checking all .html files in and under ${targdir:-`pwd`} now... (using perl)" >&2
  91. perl ${HTMLCHEK}htmlchek.pl $dprefix xref=1 refsfile=$oprefix $subopt $@ `find ${targdir:-"."} -name \*.html -print` > $oprefix.ERR
  92.     if test $? -ne 0
  93.     then echo "Note: there was apparently an error in running perl" >&2
  94.          exit 1
  95.     fi
  96.     if test ! \( -s $oprefix.NAME -a -s $oprefix.HREF -a -s $oprefix.SRC -a -s $oprefix.ERR \)
  97.     then echo "Was some error on output files; Exiting..." >&2
  98.          exit 1
  99.     fi
  100.     echo "Errorcheck data is in the file $oprefix.ERR; locations in the specified
  101.  files which are not referenced from the files are in $oprefix.NAME,
  102.  references from the specified files which are not found in the files are
  103.  in $oprefix.HREF, and references to inline images are in $oprefix.SRC;
  104.  if the map=1 option was specified, cross-dependency information is in
  105.  $oprefix.MAP" >&2
  106.     else echo "
  107. htmlchek.pl is not found.  Either copy it to the current directory, or
  108. set the environment variable HTMLCHEK to the pathname where it is located.
  109. Do \`setenv HTMLCHEK /somedir/' in csh and tcsh, \`HTMLCHEK=/somedir/;
  110. export HTMLCHEK' in sh and its offspring." >&2
  111.          exit 1
  112.     fi
  113. fi
  114. exit 0
  115.