Notes on Passthrough Print from a UNIX System by Bob Rasmussen, Rasmussen Software www.anzio.com Updated 8-22-96 --------------------------------------------- Passthrough print is the process of having a UNIX (or similar) host program print on the printer attached to your terminal (or PC running terminal emulation). Its advantages are: a) It prints where the user is, without requiring complicated procedures to equate printers with users. b) It works over direct serial, modem, multiplexor, TCP/IP, etc. c) It is immediate. All versions of Anzio respond to control codes for passthrough print, as do many dumb terminals. We have recently had several questions regarding how to implement passthrough print on a UNIX host system, where such support is not already in place. Following is a very simple approach, with NO GUARANTEES. 1) Create a shell script containing the following three lines (using your editor of choice): tput mc5 cat $* tput mc4 2) Make that shell script executable. For instance, if this script is named "passprt", do chmod +x passprt 3) If you have "root" permission, copy the shell script somewhere that everyone can access it, such as: cp passprt /usr/bin To use it, simply "pipe" your output to it. From a shell level, for instance, if you have a textfile named "somefile", you can do: cat somefile | passprt If you are working in an application environment such as a database or a COBOL runtime, you should be able to tell it to send its printer output to "passprt" rather than to "lp". The mechanism for doing so varies. We have provided some notes on doing this below. How it Works ------------ 1. The "tput mc5" line checks your TERM variable, looks up the "mc5" capability in that terminal's terminfo entry, and outputs it. "mc5" turns on passthrough print. 2. The "cat" line simply takes the input to the shell script (what you're piping to it) and sends it to the output (your terminal). Or, if you enter passprt myfile the '$*' will get replaced with the file name(s) listed, and they'll all get "catted". 3. The "tput mc4" sends out the code to turn off passthrough print. This approach using "tput" is nice because it is terminal-type independent. It relies on your terminal's terminfo file containing the 'mc4' and 'mc5' codes. If it does not have these, and you know how to manipulate terminfo entries, then try adding the following codes: For VT100, VT220, (SCO)ANSI, or AT386: mc4=\E[4i, mc5=\E[5i, For Wyse 50, 60: mc4=^T, mc5=^R, If your system doesn't have "tput", it probably doesn't have "terminfo". You may be able to rig something together, but you may need to hard-code the sequence for each terminal type. For instance, here is a string coded just for VT/ANSI-style: echo "\033[5i\c" cat $* echo "\033[4i\c" Things to Watch For ------------------- As we said above, this is a simple approach. For instance: 1. It doesn't preclude some other process from writing to your terminal at the same time, which text would then come out on your printout. 2. Any keystrokes you hit during passthrough print could disrupt handshaking. 3. Tab expansion is dependent on your "stty" setting. 4. LF to CRLF conversion is dependent on your "stty" setting. 5. There may be character set issues if you're not using all ASCII. 6. You'll get into trouble if you try to send 8-bit data over a 7-bit data line (such as if parity is enabled). Anzio Lite, AnzioWin, Passthrough Print, and the Print Wizard ------------------------------------------------------------- As mentioned above, all versions of Anzio support passthrough print. DOS versions simply pass the characters out to a file/device, such as LPT1. In Windows, we have more flexibility, and more confusion. In AnzioWin or Anzio Lite, you can choose 1) what printer to print to, 2) paper size and orientation, 3) printer font, and 4) character size. The program will then print the passthrough data using these settings. Thus if you are about to print an 80-column report, you might choose a 12-point font, and if you're doing a 132-column report, a 7-point font. But your host software may know about printer types. It may know you're printing on a LaserJet 3, and embed an escape sequence to set the character size. To keep Anzio from PRINTING that sequence instead of OBEYING it, you must set Anzio's "Low-level Print" switch on. Effective version 10.9 of AnzioWin (not Anzio Lite), we introduce Print Wizard. When this feature is turned on, it will look at the data stream coming down the passthrough print pipeline, and deal with it automatically. If the data contains escape codes (or PostScript), it will automatically print using the Low-level approach. Otherwise, the Print Wizard will determine line length and page length implied in the data, look at the paper size and orientation you've chosen, and pick font size and line-spacing automatically. This saves you (and your users) from the need to adjust these settings every time. Notes on Specific Environments: SCO ----------------------------------- SCO UNIX has a utility named 'lprint' which functions similarly to 'passprt' above, except that it uses termcap entries PN and PS to define the terminal's printer switching codes, rather than terminfo. So to use it, you may need to modify "/etc/termcap". Notes on Specific Environments: AcuCobol ---------------------------------------- AcuCobol's runtime has a capability known as 'LOCALPRINT'. Simply assign the file to either 'LOCALPRINT' or 'LOCALPRINT-C', using one of the standard file assignment techniques. This approach has the advantage that it allows an existing report program to be redirected to passthrough print without program changes or recompilation. AcuCobol has another technique involving calls to a library routine named 'C$LOCALPRINT'. This may be appropriate in cases where you want the program to always write to the passthrough channel. Because AcuCobol uses its own terminal definition file, you must ensure that your terminal's entry in that file ('/etc/a_termcap') contains the printer-on and printer-off settings. Notes on Specific Environments: RM/Cobol ---------------------------------------- RM/Cobol can be configured so that a particular device name will pipe to a certain program. Assume you've made the 'passprt' shell script shown above, and placed it in '/usr/bin/passprt'. Then, in the config file used by the RM runtime, add the following line: DEFINE-DEVICE device=PASSPRT path="/usr/bin/passprt" pipe=yes Now assume you have a program with a file assigned to 'PRINTER'. If you do: PRINTER=PASSPRT;export PRINTER the program will now print on the passthrough printer. Notes on Specific Environments: PICK and clones ----------------------------------------------- We are researching methods in PICK and its clones. Check back for update.