home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / protocol / nfs / 2753 < prev    next >
Encoding:
Internet Message Format  |  1992-11-11  |  6.9 KB

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