home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / sys / sun / admin / 8170 < prev    next >
Encoding:
Internet Message Format  |  1992-11-11  |  7.1 KB

  1. Xref: sparky comp.sys.sun.admin:8170 comp.sys.sun.hardware:5500 comp.sys.sun.misc:5209
  2. Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!agate!doc.ic.ac.uk!uknet!ieunet!ccvax.ucd.ie!bradshaw
  3. From: bradshaw@ccvax.ucd.ie
  4. Newsgroups: comp.sys.sun.admin,comp.sys.sun.hardware,comp.sys.sun.misc
  5. Subject: SUMMARY. Solution to printer filter problem.
  6. Message-ID: <1992Nov11.172132.49885@ccvax.ucd.ie>
  7. Date: 11 Nov 92 17:21:32 GMT
  8. Organization: University College Dublin
  9. Lines: 129
  10.  
  11.  
  12.      Following my posting to this (and about 6 other cross posted  newsgroups)
  13. regarding a printer filter problem which I encountered (See posting  >  Title: 
  14. HELP!!! Printer Filter Problem  Date: 3 Nov  1992),  I  received  a  flood  of 
  15. replies, some of which suggested a number of ingenious ideas,  while  an  even 
  16. larger number were requests by other users with similar problems, asking me to 
  17. forward to them any solutions I might come by. To all and sundry who took  the 
  18. time and patience to help, my sincere thanks  for  all  the  replies  to  this 
  19. posting and many others besides....... Instead  of  replying  singly  to  each 
  20. person requesting a report on my progress, I thought it  would  be  easier  to 
  21. post a summary such as this to  the  newsgroups  where  I  first  spawned  the 
  22. problem. Perhaps this could also be  of  use  to  computer-holics  in  general 
  23. ...perhaps even part of an FAQ (??!!)......the problems involved  in  reliably 
  24. interfacing printers required to print a variety of document  types  across  a 
  25. network seem to affect users  universally,  while  their  solutions  are  only 
  26. vaguely defined due to the lack of any standard method with which to  approach 
  27. the problems. 
  28.      First of all to recap my original problem.  We  have  just  upgraded  our 
  29. Hewlett Packard Laserjet IIIP to  emulate  postscript  via  the  Pacific  Page 
  30. Emulation Cartridge Ver. 4.31. This  printer  is  mounted  on  a  serial  line 
  31. (/dev/ttya) on our Sun SPARCStation, and is used not only by  the  workstation 
  32. itself, but also a small PC community using PC-NFS V3.5b.  Since  the  printer 
  33. cannot accomodate Postscript and native  HP  PCL  concurrently,  I  sought  to 
  34. enable automatic switching of the printer via an  input  filter,  which,  upon 
  35. determining the  incoming  document  type  (Postscript  or  PCL/other),  would 
  36. download an escape sequence to the printer which would reset  the  printer  to 
  37. the appropriate mode, wait  for  the  reset  to  complete  and  then  continue 
  38. printing the document itself. The escape sequences required  are  provided  in 
  39. the documentation accompanying the cartridge.
  40.      To this end, I acquired a copy of James Clark's "lprps"  software,  which 
  41. comes with an input filter program, "psif", which examines the incoming  print 
  42. file and executes a Bourne shell to enable proper handling  of  that  document 
  43. type. This software is available from many anonymous FTP sites, and comes with 
  44. C source code. In its original form, psif will execute the shell "psif-ps"  if 
  45. the incoming print document is  Postscript,  and  "psif-text"  for  all  other 
  46. types. I therefore set up the  shells  to  not  only  print  the  document  in 
  47. question, but to also download the appropriate escape sequence and "sleep" for 
  48. 40 seconds before printing. The  only  problem  I  had  was  that  when  using 
  49. "psif-text" to switch from Postscript to HP PCL, the printer seemed  to  still 
  50. receive data even during the "sleep  40",  after  which  the  following  error 
  51. appeared on the first page of the printout:
  52.  
  53. %%[ Error: undefined; OffendingCommand: %%
  54. [
  55.  
  56.      The solution to the problem eventually came from Markus Hirt  and  Ronald 
  57. Florence.....all that was required was to include a '%' at  the  beginning  of 
  58. the escape sequence, so that the sequence is interpreted as a valid Postscript 
  59. command. My  thanks  to  both  Markus  and  Ronald.....the  filter  now  works 
  60. perfectly. Here is the printcap entry I use (If you're  mounting  the  printer 
  61. remotely via PC-NFS use the "raw" filter option in NFSCONF):
  62.  
  63. # Hewlett Packard LaserJet IIIP
  64.  
  65. ljet:\
  66.      :lp=/dev/ttya:br#19200:\                # Printer is on serial line ttya
  67.      :sd=/var/spool/lpd:\
  68.      :lf=/var/spool/lpd/log:\
  69.      :rw:sb:sh:sf:\
  70.      :if=/usr/local/lib/psif:\               # Input filter
  71.      :tr=\004:                               # ^D required in postscript
  72.                                              # mode to tell the printer
  73.                                              # when end of job is reached.
  74.  
  75. If the incoming document is in  postscript  format,  the  shell  "psif-ps"  is 
  76. executed by the input filter program psif:
  77.  
  78. #!/bin/sh
  79. # psif-ps > A shell to switch printer to postscript if it is  not  already  in 
  80. # postscript mode. The shell checks for the existence of an empty file  called 
  81. # "pcl", which if found means the printer is in native HP PCL mode. An  escape 
  82. # sequence is then sent to the printer to switch the  printer  to  postscript, 
  83. # and the file "pcl" is renamed "postscript", signifying that the  printer  is 
  84. # now in that mode:
  85.  
  86. if [ -f /var/spool/lpd/printer_mode/pcl ]; then
  87.  
  88.      mv /var/spool/lpd/printer_mode/pcl /var/spool/lpd/printer_mode/postscript
  89.  
  90.      echo ["^[&l5257.1058J^M"]     # Send escape sequence to standard output
  91.                                    # i.e. the printer.
  92.  
  93.      sleep 40                      # Put this shell to "sleep" for 40 seconds
  94.                                    # and wait for reset to complete.
  95.  
  96.      cat                           # Send standard input (print file) to 
  97.                                    # standard output (printer).
  98.  
  99. else
  100.  
  101.      cat                           # If printer is already in postscript mode
  102.                                    # just print document.
  103. fi
  104.  
  105. If the incoming print file  is  anything  other  than  Postscript,  the  shell 
  106. "psif-text" is executed in a similar manner:
  107.  
  108. #!/bin/sh
  109. # psif-text > A shell to switch printer to Hp PCL mode if not already in  that 
  110. # mode. Operation is similar to above script, psif-ps.
  111.  
  112. if [ -f /var/spool/lpd/printer_mode/postscript ]; then
  113.  
  114.      mv /var/spool/lpd/printer_mode/postscript /var/spool/lpd/printer_mode/pcl
  115.  
  116.      echo ["%^[&l1057.32259J^M"]   # Send escape sequence....note leading '%'.
  117.  
  118.      sleep 40                      # Wait for printer to reset.
  119.  
  120.      cat                           # Print actual print data.
  121.  
  122. else
  123.  
  124.      cat                           # Printer already in HP PCL mode. Only need
  125.                                    # to print document..no switching required.
  126. fi
  127.  
  128.      Note I have used the SunOS echo command. To put an escape character  such 
  129. as Esc (ASCII 27 in decimal)into the echo argument,  use  the  vi  editor  and 
  130. press Ctrl V and then Ctrl [. I hope that the above is of some  use  to  those 
  131. who requested it and perhaps also to those who did  not.  If  anyone  has  any 
  132. questions or problems please feel free to e-mail me at either of the addresses 
  133. below. Once again thanks to one and all for all  the  replies  and  thanks  to 
  134. Markus and Ronald. 'Till we meet again on the news-net.....
  135.  
  136.                                              Chris Bradshaw
  137.  
  138.                CBRADH89@IRLEARN.UCD.IE
  139.                BRADSHAW@CCVAX.UCD.IE
  140.