home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume20 / epf / part01 / epson < prev    next >
Text File  |  1989-10-24  |  3KB  |  140 lines

  1. # iPAX286 lp interface for dumb parallel line printer
  2. # configured for Epson LQ-800
  3. # and enough options to handle tbl|eqn|nroff output
  4. #
  5. #ident    "@(#)    1.2"
  6. #
  7. #
  8.  
  9. DEFAULT="\033@"                #printer configuration strings
  10. UNION="\033U\001"
  11. UNIOFF="\033U\000"
  12. DRAFT="\033x\000"
  13. NLQ="\033x\001"
  14. PICA="\033P"
  15. ELITE="\033M"
  16.  
  17. TRON="/usr/local/bin/lptoggle 1"    #reconfigure printer port
  18. TROFF="/usr/local/bin/lptoggle 0"    #restore printer port to defaults
  19. NTOEPS="| /usr/local/bin/nroff.to.epson"
  20. RESET=""        #load with printer control strings to restore 
  21.             #printer defaults
  22. LPRESET=""        #set to $TROFF if need to restore printer port
  23. FILTER="-v"        #default to remove ctrl chars - else may pass thru
  24.             #unwanted printer control codes
  25.             #set to $NTOEPS for printing of nroff output
  26. x="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
  27.  
  28. #use lp -o<options> in $5 to setup and restore the printer;
  29. #probably there should be a man page or usage message, even though the
  30. #option list is pretty obvious and mnemonic.
  31.  
  32. echo $5|egrep 'nroff|filter' >/dev/null
  33. if [ $? -eq 0 ]
  34. then
  35.     FILTER="$NTOEPS"
  36. fi
  37. echo $5|egrep 'epson|nofilter' >/dev/null
  38. if [ $? -eq 0 ]
  39. then
  40.     FILTER=""
  41. fi
  42. echo $5|egrep 'nroff|setlp|lpset|tron' >/dev/null
  43. if [ $? -eq 0 ]
  44. then
  45.     LPRESET="$TROFF"
  46. fi
  47. echo $5|egrep 'nroff|lq|resetdraft' >/dev/null
  48. if [ $? -eq 0 ]
  49. then
  50.     RESET="$DRAFT$RESET"
  51. fi
  52. echo $5|egrep 'nroff|12|elite|resetpica' >/dev/null
  53. if [ $? -eq 0 ]
  54. then
  55.     RESET="$PICA$RESET"
  56. fi
  57. echo $5|egrep 'resetall|resetdefault' >/dev/null
  58. if [ $? -eq 0 ]
  59. then
  60.     RESET="$DEFAULT$RESET"
  61. fi
  62. echo $5|egrep 'uni[^ ]*on|resetuni' >/dev/null
  63. if [ $? -eq 0 ]
  64. then
  65.     RESET="$UNIOFF$RESET"
  66. fi
  67. for i in $5
  68. do
  69.     case $i in
  70.     nroff|setlp|lpset|tron) 
  71.         eval $TRON ;;
  72.     troff)
  73.         eval $TROFF ;;
  74.     uni*off)    
  75.         echo "$UNIOFF" ;;
  76.     uni*on)    
  77.         echo "$UNION" ;;
  78.     nlq|lq)    
  79.         echo "$NLQ" ;;
  80.     draft)    
  81.         echo "$DRAFT" ;;
  82.     10|pica)    
  83.         echo "$PICA" ;;
  84.     12|elite)    
  85.         echo "$ELITE" ;;
  86.     default)    
  87.         echo "$DEFAULT"
  88.         eval $TROFF ;;
  89.     filter|epson|nofilter|reset*) 
  90.         ;;
  91.     *)
  92.         echo bad option;exit 1 ;;
  93.     esac
  94. done
  95.  
  96. printer=`basename $0`
  97. copies=$4
  98.  
  99. if [ X${BANNER:+yes} = Xyes ]
  100. then
  101.     echo "$x\n$x\n$x\n$x\n"
  102.     banner "$2"
  103.     echo "\n"
  104.     user=`grep "^$2:" /etc/passwd | line | cut -d: -f5`
  105.     if [ -n "$user" ]
  106.     then
  107.         echo "User: $user\n"
  108.     else
  109.         echo "\n"
  110.     fi
  111.     echo "Request id: $1    Printer: $printer\n"
  112.     date
  113.     echo "\n"
  114.     if [ -n "$3" ]
  115.     then
  116.         banner $3
  117.     fi
  118.     echo "Print Options:  \n"
  119.     echo "        Copies="$copies"\n"
  120.     echo "\014\c"
  121. fi  
  122.  
  123. shift; shift; shift; shift; shift
  124. files="$*"
  125. i=1
  126. while [ $i -le $copies ]
  127. do
  128.     for file in $files
  129.     do
  130.         eval cat $FILTER "$file" 2>&1
  131.         echo "\014\c"
  132.     done 
  133.     i=`expr $i + 1`
  134. done
  135. echo "$x\n$x\n$x\n$x\n" 
  136. echo "\014\c" 
  137. echo "${RESET}\c" 
  138. eval ${LPRESET}
  139. exit 0
  140.