home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / unix / sysv386 / 16363 < prev    next >
Encoding:
Internet Message Format  |  1992-11-10  |  4.3 KB

  1. Path: sparky!uunet!news.centerline.com!noc.near.net!hri.com!spool.mu.edu!nigel.msen.com!sdd.hp.com!cs.utexas.edu!usc!sol.ctr.columbia.edu!emory!kd4nc!n4hgf!wa4cyb!jmd
  2. From: jmd@wa4cyb.UUCP (John Dashner)
  3. Newsgroups: comp.unix.sysv386
  4. Subject: Re: SCO Unix : HELP WITH HP PRINTERS:
  5. Message-ID: <2@wa4cyb.UUCP>
  6. Date: 10 Nov 92 06:49:14 GMT
  7. References: <1992Nov5.182123.6204@cs.wayne.edu>
  8. Organization: John Dashner & Assoc.
  9. Lines: 129
  10. X-Newsreader: TIN [version 1.1 PL6]
  11.  
  12. In article <1992Nov5.182123.6204@cs.wayne.edu> mikeg@rocdec.roc.wayne.edu (Michael George) writes:
  13. >If anyone out there is running SCO UNIX with a HP Laserjet as your
  14. >NETWORK PRINTER, please drop me a line. I am having much trouble getting
  15. >it to work here on my end. I believe the problem lies somewhere in the
  16. >print filter. PLEASE HELP IF YOU CAN!!!!!!
  17. >Actualy, the hardware is all fine, and I can print to the printer except
  18. >the output is wrong. Page Breaks aren't in the right place etc...
  19.  
  20. Unless you've had to deal with this problem, you can't possibly imagine
  21. how frustrating it is.  Before I include a filter that works for me, let me
  22. explain why the HP LaserJet is problematic for UNIX users - IT WAS DESIGNED
  23. FOR DOS!!!! ;-)
  24.  
  25. Herewith follows an lp filter/interface that might resemble others
  26. you have seen only because I probably ripped off their good ideas.
  27. But, I have been experimenting and hacking on this for some time and
  28. it seems to handle the cases I'm interested in:
  29.  
  30.     1. printing landscape in line printer font
  31.     2. printing portrait with line printer font
  32.     3. oh, yea, printing ``normally''
  33.  
  34. Usage with the lp spooling command:
  35.  
  36.     lp -o {b,[lL],[wW]} ... (remainder of options, files, etc.)
  37.     where:
  38.         b      = print a banner
  39.         l or L = Landscape with line printer font
  40.         w or W = Wide (portrait with lineprinter font)
  41.  
  42. This filter handles: a) Unix end-of-line conventions; b) proper settings
  43. to get the ``normal'' output of ``nroff -man'' to print correctly; and
  44. takes care of setting (or resetting) the printer back to its normal mode.
  45. I threw this last ``feature'' in when I was sharing the printer between
  46. a DOS and a Unix system.  It turned out that it handled the final page
  47. eject as well - life can be neat at times. Note the line about use of
  48. the parallel printer interface, /dev/lp and its friends, i.e., comment
  49. out the ``stty'' line if you are using a parallel printer interface
  50. rather than a serial line.
  51.  
  52. Uh, oh.  just reread the post.  It says ``NETWORK PRINTER'' - does
  53. this mean that you are spooling to another machine on a TCP/IP network??
  54. if so, then the filter should simply cat(C) (or if you prefer, cat(1) ;-)
  55. the file thru a ``rcmd'' (damn SCO for their man pages and renaming this
  56. command) something like
  57.  
  58.     ... after all the shifting below ....
  59.     while [ -s "$1" ] #or whatever the shell uses to test for len > 1
  60.     do    cat $1 | rcmd <remote-sys-name> lp
  61.         shift
  62.     done
  63.  
  64. Now I know this won't pass options, copies etc., but that's all I got
  65. time to think about rite now...... otherwise, if the problem is just how to
  66. talk to the laser attached locally then use the following - in fact, use it
  67. on the remote printer's system too!!
  68.  
  69. ============================ snip here ===============================
  70. :
  71. #
  72. #    LaserJet interface that's all you need
  73. #
  74.  
  75. printer=`basename $0`
  76. request=$1
  77. name=$2
  78. title=$3
  79. copies=$4
  80. options=$5
  81. shift; shift; shift; shift; shift
  82.  
  83. Landscape=no
  84. Wide=no
  85. banner=no
  86.  
  87. for i in $options
  88. do
  89.     case $i in
  90.     l|L)        Landscape=yes
  91.             ;;
  92.     w|W)        Wide=yes
  93.             ;;
  94.     b)        banner=yes
  95.             ;;
  96.     *)
  97.             ;;
  98.     esac
  99. done
  100.  
  101. # Set up interface
  102. # NOTE: COMMENT OUT THE FOLLOWING LINE IF YOU ARE USING /dev/lp
  103. stty raw 19200 -parenb cs8 ixon -istrip clocal <&1 2>/dev/null
  104.  
  105. if [ "$banner" = yes ] 
  106. then
  107.     echo "\033E\033&l0o7.27c66F\033&k2G\c"
  108.     
  109.     sysid=`uname -n`
  110.  
  111.     #user = fifth field of /etc/passwd
  112.     user=`sed -n "s/^$name:.*:.*:.*:\(.*\):.*:.*$/\1/p" /etc/passwd`
  113.     banner "$name"
  114.     [ "$user" ] && echo "User: $user\n"
  115.     echo "Request id: $requests\n"
  116.     echo "Printer: $printer\n"
  117.     echo "Options: $options\n"
  118.     date
  119.     echo "\nMachine: $sysid\n"
  120. fi
  121. while [ "$copies" -gt 0 ]
  122. do
  123.     for file
  124.     do
  125.         if [ "$Landscape" = yes ]
  126.         then
  127.             echo "\033E\033&l1o5.45c66F\033(s16.66H\033&k2G\c"
  128.         elif [ "$Wide" = yes ]
  129.         then
  130.             echo "\033E\033&l0o7.27c66F\033(s16.66H\033&k2G\c"
  131.         else
  132.             echo "\033E\033&l0o7.27c66F\033&k2G\c"
  133.         fi
  134.         cat "$file" 2>&1
  135.         echo "\033E\c"
  136.     done
  137.     copies=`expr $copies - 1`
  138. done
  139. exit 0
  140.