home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / wvhtm064.zip / wv / wvText < prev    next >
Text File  |  2001-02-04  |  1KB  |  56 lines

  1. #!/bin/sh
  2.  
  3. prefix=/usr/local
  4. exec_prefix=${prefix}
  5. datadir=${prefix}/share
  6.  
  7. # argument checking
  8. if [ ${#} -ne "2" ]; then
  9.     echo "Usage: ${0} <word document> <text output file>"
  10.     exit 1
  11. fi
  12.  
  13. # start out optimistic
  14. USING_LYNX=1
  15. which lynx >/dev/null 2>&1
  16. if [ ${?} -ne "0" ]; then
  17.     echo "Could not find required program 'lynx'"
  18.     echo "Not using lynx. Ouput will be pretty bad."
  19.     USING_LYNX=0
  20. fi
  21.  
  22. if [ ${USING_LYNX} -ne "0" ]; then
  23.  
  24.     # first, test for wvHtml
  25.     which wvHtml >/dev/null 2>&1
  26.     if [ ${?} -ne "0" ]; then
  27.            echo "Could not find required program 'wvHtml'"
  28.     exit 1
  29.     fi
  30.  
  31.     # intermediate file
  32.     TMP_FILE="/tmp/wv${1}.html"
  33.  
  34.     wvHtml "${1}" "${TMP_FILE}" >/dev/null 2>&1
  35.     if [ ${?} -ne "0" ]; then
  36.     echo "Could not convert into HTML"
  37.     exit 1
  38.     fi
  39.  
  40.     # lynx actually does quite well
  41.     lynx -dump -force_html "${TMP_FILE}" > "${2}"
  42.     if [ ${?} -ne "0" ]; then
  43.         echo "Could not convert into Text"
  44.         exit 1
  45.     fi
  46.  
  47.     # clean up
  48.     rm -f ${TMP_FILE}
  49.  
  50. else
  51.     # fall back onto our cruddy output
  52.     # this is, admittedly, better than running
  53.     # 'strings' on the word document though :)
  54.     wvWare -x ${datadir}/wv/wvText.xml "${1}" > "${2}"
  55. fi
  56.