TEXT   42

Notes on Passthrough Print from a UNIX System

Guest on 21st April 2022 01:15:53 AM

  1. Notes on Passthrough Print from a UNIX System
  2. by Bob Rasmussen, Rasmussen Software
  3. ---------------------------------------------
  4. Passthrough print is the process of having a UNIX (or similar) host program
  5. print on the printer attached to your terminal (or PC running terminal
  6. emulation). Its advantages are:
  7.    a) It prints where the user is, without requiring complicated procedures
  8.       to equate printers with users.
  9.    b) It works over direct serial, modem, multiplexor, TCP/IP, etc.
  10.    c) It is immediate.
  11.  
  12. All versions of Anzio respond to control codes for passthrough print, as do
  13. many dumb terminals. We have recently had several questions regarding how to
  14. implement passthrough print on a UNIX host system, where such support is not
  15. already in place. Following is a very simple approach, with NO GUARANTEES.
  16.  
  17. 1) Create a shell script containing the following three lines (using
  18.    your editor of choice):
  19.       tput mc5
  20.       cat $*
  21.       tput mc4
  22.  
  23. 2) Make that shell script executable. For instance, if this script is named
  24.    "passprt", do
  25.       chmod +x passprt
  26.  
  27. 3) If you have "root" permission, copy the shell script somewhere that
  28.    everyone can access it, such as:
  29.       cp passprt /usr/bin
  30.  
  31. To use it, simply "pipe" your output to it. From a shell level, for instance,
  32. if you have a textfile named "somefile", you can do:
  33.    cat somefile | passprt
  34.  
  35. If you are working in an application environment such as a database or a
  36. COBOL runtime, you should be able to tell it to send its printer output to
  37. "passprt" rather than to "lp". The mechanism for doing so varies. We have
  38. provided some notes on doing this below.
  39.  
  40. How it Works
  41. ------------
  42. 1. The "tput mc5" line checks your TERM variable, looks up the "mc5" capability
  43.    in that terminal's terminfo entry, and outputs it. "mc5" turns on
  44.    passthrough print.
  45.  
  46. 2. The "cat" line simply takes the input to the shell script (what you're
  47.    piping to it) and sends it to the output (your terminal). Or, if you enter
  48.       passprt myfile
  49.    the '$*' will get replaced with the file name(s) listed, and they'll all
  50.    get "catted".
  51.  
  52. 3. The "tput mc4" sends out the code to turn off passthrough print.
  53.  
  54. This approach using "tput" is nice because it is terminal-type independent.
  55. It relies on your terminal's terminfo file containing the 'mc4' and 'mc5'
  56. codes. If it does not have these, and you know how to manipulate terminfo
  57. entries, then try adding the following codes:
  58.    For VT100, VT220, (SCO)ANSI, or AT386: mc4=\E[4i, mc5=\E[5i,
  59.    For Wyse 50, 60: mc4=^T, mc5=^R,
  60.  
  61. If your system doesn't have "tput", it probably doesn't have "terminfo". You
  62. may be able to rig something together, but you may need to hard-code the
  63. sequence for each terminal type. For instance, here is a string coded just
  64. for VT/ANSI-style:
  65.    echo "\033[5i\c"
  66.    cat $*
  67.    echo "\033[4i\c"
  68.  
  69. Things to Watch For
  70. -------------------
  71. As we said above, this is a simple approach. For instance:
  72.  
  73. 1. It doesn't preclude some other process from writing to your terminal at
  74.    the same time, which text would then come out on your printout.
  75. 2. Any keystrokes you hit during passthrough print could disrupt handshaking.
  76. 3. Tab expansion is dependent on your "stty" setting.
  77. 4. LF to CRLF conversion is dependent on your "stty" setting.
  78. 5. There may be character set issues if you're not using all ASCII.
  79. 6. You'll get into trouble if you try to send 8-bit data over a 7-bit data line
  80.    (such as if parity is enabled).
  81.  
  82. Anzio Lite, AnzioWin, Passthrough Print, and the Print Wizard
  83. -------------------------------------------------------------
  84. As mentioned above, all versions of Anzio support passthrough print. DOS
  85. versions simply pass the characters out to a file/device, such as LPT1.
  86. In Windows, we have more flexibility, and more confusion.
  87.  
  88. In AnzioWin or Anzio Lite, you can choose 1) what printer to print to,
  89. 2) paper size and orientation, 3) printer font, and 4) character size. The
  90. program will then print the passthrough data using these settings. Thus if
  91. you are about to print an 80-column report, you might choose a 12-point font,
  92. and if you're doing a 132-column report, a 7-point font.
  93.  
  94. But your host software may know about printer types. It may know you're
  95. printing on a LaserJet 3, and embed an escape sequence to set the character
  96. size. To keep Anzio from PRINTING that sequence instead of OBEYING it, you must
  97. set Anzio's "Low-level Print" switch on.
  98.  
  99. Effective version 10.9 of AnzioWin (not Anzio Lite), we introduce Print Wizard.
  100. When this feature is turned on, it will look at the data stream coming down the
  101. passthrough print pipeline, and deal with it automatically. If the data
  102. contains escape codes (or PostScript), it will automatically print using the
  103. Low-level approach. Otherwise, the Print Wizard will determine line length and
  104. page length implied in the data, look at the paper size and orientation you've
  105. chosen, and pick font size and line-spacing automatically. This saves you (and
  106. your users) from the need to adjust these settings every time.
  107.  
  108. Notes on Specific Environments: SCO
  109. -----------------------------------
  110. SCO UNIX has a utility named 'lprint' which functions similarly to 'passprt'
  111. above, except that it uses termcap entries PN and PS to define the terminal's
  112. printer switching codes, rather than terminfo. So to use it, you may need to
  113. modify "/etc/termcap".
  114.  
  115. Notes on Specific Environments: AcuCobol
  116. ----------------------------------------
  117. AcuCobol's runtime has a capability known as 'LOCALPRINT'. Simply assign the
  118. file to either 'LOCALPRINT' or 'LOCALPRINT-C', using one of the standard file
  119. assignment techniques. This approach has the advantage that it allows an
  120. existing report program to be redirected to passthrough print without program
  121. changes or recompilation.
  122.  
  123. AcuCobol has another technique involving calls to a library routine named
  124. 'C$LOCALPRINT'. This may be appropriate in cases where you want the program to
  125. always write to the passthrough channel.
  126.  
  127. Because AcuCobol uses its own terminal definition file, you must ensure that
  128. your terminal's entry in that file ('/etc/a_termcap') contains the printer-on
  129. and printer-off settings.
  130.  
  131. Notes on Specific Environments: RM/Cobol
  132. ----------------------------------------
  133. RM/Cobol can be configured so that a particular device name will pipe to a
  134. certain program. Assume you've made the 'passprt' shell script shown above,
  135. and placed it in '/usr/bin/passprt'. Then, in the config file used by the RM
  136. runtime, add the following line:
  137.    DEFINE-DEVICE device=PASSPRT path="/usr/bin/passprt" pipe=yes
  138.  
  139. Now assume you have a program with a file assigned to 'PRINTER'. If you do:
  140.    PRINTER=PASSPRT;export PRINTER
  141. the program will now print on the passthrough printer.
  142.  
  143. Notes on Specific Environments: PICK and clones
  144. -----------------------------------------------
  145. We are researching methods in PICK and its clones. Check back for update.

Raw Paste


Login or Register to edit or fork this paste. It's free.