|
"Modular DocBook HTML Stylesheet Version 1.71 ">
"#0000FF" vlink="#840084" alink="#0000FF">
IFHP-HOWTO1 Apr 2002 (For ifhp-3.5.7)Patrick A Powellpapowell@astart.com Copyright © 2002 by Patrick Powell The ifhp program is an enhanced, extended, highly configurable, and portable implementation of a print filter for use with the LPRng Print spooler package. ifhp supports network, serial, and parallel printers, does page accounting and job recovery, and allows an extremely high level of configuration and tuning. ifhp gets its flexibility by using a configuration file to set its operational characteristics. The configuration file can contain multiple separate printer configurations and the configuration selection is done by a very simple command line option. The filter supports text, PostScript, PCL, and PJL printers, and can be configured to handle a wide range of printer quirks and mis-implementations.
Preface1. IntroductionThe ifhp Print Filter is the primary print filter for the LPRng Print Spooler. This document is designed to be the single basic reference for the ifhp software; the LPRng software is distributed separately and has additional documentation. 2. AcknowledgementsI would like to thank all of the LPRng users who so relentlessly tried the incredible number of permutations and combinations of printers and software, and whose requests for just one more feature led to the development of the software. 3. Shell PromptsThe following table shows the default system prompt and superuser prompt. The examples will use this prompt to indicate which user you should be running the example as. 4. Typographic ConventionsThe following table describes the typographic conventions used in this book.
5. Notes, warnings, and examplesWithin the text appear notes, warnings, and examples.
Chapter 1. IntroductionThe ifhp print filter is the latest in a long evolutionary path of print filters for the LPRng print spooler system. It unifies the low level printer communication facilities and provide a common code base for future development. This document is the complete set of references and installation guide for the ifhp print filter. It covers compilation, installation, initial testing, details of system configuration, and configuration options that would be needed by the system administrator. Previous releases of ifhp had a large selection of README files which are now incorporated into the IFHP-HOWTO document. Information about LPRng and ifhp can be found on the LPRng web page http://www.lprng.com. There is mailing list for ifhp and LPRng at <lprng@lprng.com>. In order to reduce the amount of unsolicited spam mail posted to the list you must subscribe to the list before posting to it. To subscribe, send email message to lprng-request@lprng.com, with the single word subscribe in the body. Several presentations of LPRng and print spooling software have been made at the Large Scale Installation Administrator (LISA) conferences and are in the ifhp distribution and available on web sites. The slides for the LISA 97 tutorial on Printers and Network Print Spooling are the LISA97.ppt in the LPRng distribution. During development of ifhp, the following documents were invaluable references. For Printer Job Language (PJL) related issues see the Printer Job Language Technical Reference Manual, Hewlett Packard, 10th Edition, October 1997. For PCL related issues see the PCL 5 Printer Language Technical Reference Manual, First Edition, 1992. These manuals are available through the Hewlett Packard Developers Program. See http://www.hp.com/go/devexchange for information on how to join. 1.1. Copyright and DisclaimerMaterial included in this document from the ifhp distribution Copyright Patrick Powell 1988-1999, where applicable. The rights to distribute this document complete or in part are hereby granted for non-commercial purposes. Partial reproductions must acknowledge the source. Permission to distribute this file together with LPRng, ifhp and `derived works' is explicitly granted. THE MATERIAL IN THIS HOWTO IS PROVIDED WITHOUT FEE AND AS-IS WITH NO WARRANTY REGARDING FITNESS OF USE FOR ANY PURPOSE. THE AUTHOR AND ALL CONTRIBUTORS ARE NOT LIABLE FOR ANY DAMAGES, DIRECT OR INDIRECT, RESULTING FROM THE USE OF INFORMATION PROVIDED IN THIS DOCUMENT. 1.2. Commercial SupportAStArt Technologies (http://www.astart.com) provides commercial support and enhancements for LPRng, ifhp, and other network software. AStArt provides network and system consulting services for UNIX and NT systems, as well as real time and network software. 1.4. FTP SitesMain FTP Site:
Mirrors: 1.5. Mailing ListTo join the LPRng mailing list, please send mail to lprng-request@lprng.ie with the only the word subscribe in the body of the message. 1.6. PGP Public KeyThe LPRng and ifhp distributions have MD5 checksum files which are signed with a PGP public key. Here is the key for validating the checksums: Type Bits/KeyID Date User ID pub 1024/00D95C9D 1997/01/31 Patrick A. Powell <papowell@astart.com> Patrick A. Powell <papowell@sdsu.edu> -----BEGIN PGP PUBLIC KEY BLOCK----- Version: 2.6.3i mQCNAzLygTQAAAEEANBW5fPYjN3wSAnP9xWOUc3CvsMUxjip0cN2sY5qrdoJyIhn qbAspBopR+tGQfyp5T7C21yfWRRnfXmoJ3FVtgToAsJUYmzoSFY08eDx+rmSqCLe rdJjX8aG8jVXpGipEo9U4QsUK+OKzx3/y/OaK4cizoWqKvy1l4lEzDsA2VydAAUT tCdQYXRyaWNrIEEuIFBvd2VsbCA8cGFwb3dlbGxAYXN0YXJ0LmNvbT6JAJUDBRA0 XonoiUTMOwDZXJ0BAQ2cBAC7zU9Fn3sC3x0USJ+3vjhg/qA+Gjb5Fi1dJd4solc4 vJvtf0UL/1/rGipbR+A0XHpHzJUMP9ZfJzKZjaK/d0ZBNlS3i+JnypypeQiAqo9t FV0OyUCwDfWybgAORuAa2V6UJnAhvj/7TpxMmCApolaIb4yFyKunHa8aBxN+17Ro rrQlUGF0cmljayBBLiBQb3dlbGwgPHBhcG93ZWxsQHNkc3UuZWR1PokAlQMFEDLy gTSJRMw7ANlcnQEBYBYD/0zTeoiDNnI+NjaIei6+6z6oakqO70qFVx0FG3aP3kRH WlDhdtFaAuaMRh+RItHfFfcHhw5K7jiJdgKiTgGfj5Vt3OdHYkeeh/sddqgf9YnS tpj0u5NfrotPTUw39n6YTgS5/aW0PQfO9dx7jVUcGeod1TGXTe9mIhDMwDJI4J14 =3Zbp -----END PGP PUBLIC KEY BLOCK----- Chapter 2. Software Installation and ConfigurationBefore you do an installation please read the following instructions. You will need to:
2.1. Additional Recommended SoftwareThe following software is recommended for use with ifhp. If your printer does not support PostScript, PCL, or text printing directly you will need to install GhostScript to convert from PostScript to the printer format and use a suitable text to PostScript converter.
2.2. InstallationThe installation procedure uses the configure facility to generate Makefiles. By convention, these files have the following variables that install the ifhp executables and configuration files in the following locations: Table 2-1. Configure File Location Variables
The following files are installed as shown below: Table 2-2. Executable and Configuration File Locations
The configuration you choose should match that of the LPRng print spooler. For example: ./configure --prefix=/usr --sysconfdir=/etc \ --mandir=/usr/share/man executables and files in /usr/libexec/filters ifhp /etc ifhp.conf /usr/share/man/man[0-9] ifhp.man1 First, we untar, configure, compile, and install the software: h4: {1} % gunzip -c ifhp-<version>.tgz | tar xvf - h4: {2} % cd ifhp-<version> h4: {3} % ./configure [ ... configuration options ] h4: {4} % make clean all h4: {5} % su # you must do the following commands as root h4: {6} # make install Modify your printcap file to use ifhp. Your printcap usually has the following format; older version of lpd require :\ at the end of each line of a printcap entry. The :if and :of filter entries are usually the ones of interest. lp: :lp=xxxx:sd=xxxx:.... :if=/usr/local/path_to_old_filters/old_if_filter :of=/usr/local/path_to_old_filters/old_of_filter Your new printcap entry will look like the one below. The MODEL information is described in the next section. lp: :lp=xxxx:sd=xxxx:.... # see text for details about the next line :ifhp=model=MODEL,status@ :filter=/usr/local/libexec/filters/ifhp # only if you are using accounting or banners #:of=/usr/local/libexec/filters/ifhp Select a suitable printer from the entries in the configuration file (/usr/local/etc/lpd.conf or /etc/lpd.conf). These are described in more detail in the next section. Shut down and restart your print spooler and then send a job to the printer. If this works and you do not need any further capabilities of ifhp such as error reporting or printer monitoring, then you are finished. If you want to use additional capabilities, then you should read the detailed instructions in the next couple of sections. 2.3. Printer Models SupportedThere are over 500 different printer models, types and configurations supported by ifhp. If your printer is not currently supported and you have documentation about the printer then send mail to the LPRng Mailing List and support will be added. The default printer is an HP LaserJet 4MP, which supports PostScript Level 3, PCL5, PJL, and has bidirectional communication and a functional pagecounter. The ifhp.conf configuration file contains configuration entries for various models of printers. Each entry has a name usually corresponding to the model of printer or its basic capabilities. For example, the HP LaserJet 4 printer has the model=hp4 configuration entry. The default printer configuration covers a wide range of network printers manufactured by Hewlett-Packard, Canon, Epson, and others and is for a printer that has a bidirectional communications connection that allows it to report status information and the following capabilities:
There is also support for PostScript only printers (model=ps), Tektronics Phasers (model=phaser), QMS (model=qmsXXX) and others. The best way to determine the printers currently supported is to examine the ifhp.conf file. The following is a sample of the various entries in the configuration file. Table 2-3. ifhp.conf Configuration Entries
If your printer is not in this this list then you can use the following guidelines. If you have a PostScript only printer you should use the ps model. If you have a PCL only printer, then pcl is recommended. If you want to process PostScript files on your PCL only printer then install GhostScript and use pcl_ps entry and select the GhostScript driver suitable for your printer. The other model entries are used when specific printer functionality or features are needed. For example, if you want to do accounting or use landscape mode, then you should check for your specific printer model in the configuration file. Chapter 3. Recommended -Z options for UsersDue to the general nature of the ifhp filter, there is no standard set of -Z user options because there is no standard set of user facilities. However, the following are recommended for use by implementors of new configurations or printer support. 3.1. Input Tray SelectionIf a printer supports an input tray selection mechanism, then the following options are recommended for use. Local conditions or printer type may require addition options.
3.2. Output Bin SelectionIf a printer has an output bin selection mechanism or some other finishing mechanism, then the following are recommended for use.
3.3. Media Size (Paper) SelectionThe paper size selection facilities usually are quite printer dependent, and the input tray selection and paper size selection mechanisms may interact in strange and mysterious ways.
3.4. Media Type SelectionMedia Type is not the same as paper size, and corresponds to the name assigned to a particular media. Of course, the issue is complicated by the fact that some media have standard sizes as well. Again, the input tray selection, media size, and media type selection will interact in confusing and mysterious ways, depending on the whim of the printer firmware implementors. You will also notice that there is no general mediatype=name selection mechanism. This is due to the extremely different way that the media names must be passed for PostScript, PJL, and PCL.
3.5. Duplex and SimplexDuplex printing is when impressions are placed on both sides of a sheet of media. Due to a general lack of conventions, the orientation of each of the impressions varies from vendor to vendor, and has changed over the years.
3.6. CopiesThis option has been provided to effectively allow the printer to make multiple copies of a single page or job. This option tends to be misimplemented on almost all known printers, and it is strongly recommended that users do not use it. However, for completeness, compatibility, and implementor consideration, this is included, even against the better judgement of the implementors of the ifhp software.
Chapter 4. Printer Capabilities, Configurations, and PrintcapsOne of the major difficulties with printer software is dealing with the wide range of different printer hardware configurations and printer connections. This section outlines the printer communication methods, the types of print job languages, and the effects of these on printing software and the ifhp filter. 4.1. Printer ConfigurationsA printer consists of a hardware print engine which marks the output page and delivers it, a set of control hardware that takes a print job in a well defined format and operates the hardware to produce output according to information in the print job, and a communication channel from the computer to the control hardware. The control hardware is sometimes called a print engine. In most modern computers the control hardware may consist of multiple microprocessors, each with their own firmware, and each performing a specific printing task. For example, one may control the paper feed path, one may do rasterization, and one may handle communications with the outside world. In order to set up printing correctly, it is necessary to know the following information about your printer.
Usually the capabilities of a modern printer are very well known and documented, and the ifhp filter and most print spooling software has little difficulty working with them. The following checklist will help you in setting up your printer. The various options that you will need to know about are indicated where appropriate.
4.2. Network Communication ProtocolsThe most high speed and reliable connection to your printer is using a network connection. The following protocols are usually used to communicate with a network printer: RFC1179 (TCP/IP printing), Socket Protocol (TCP/IP), AppSocket Protocol (TCP/IP), Novell Print Protocol (IPX), SMB Print Protocol (TCP/IP), and AppleTalk Print Protocol (TCP/IP). It is highly recommended that you use TCP/IP networking to communications to talk to your printer, and that you do not enable any other protocol on your printer. If you have two different systems trying to connect to the same printer using different protocols, a wide range of vendor's hardware will lock up and may require a power up reset to recover. Documented evidence for this behavior includes a wide range of printers, including those from Hewlett-Packard, LexMark, IBM and other vendors. Only the TCP/IP based network job transfer protocols are discussed in this document. For details on using other protocols, please consult the consult the LPRng documentation. 4.3. RFC1179 (BSD or TCP/IP) Job Transfer Printcap EntryRFC1179 is used to transfer print jobs between a client (user) and a print spooler, or between two print spoolers. Jobs are transferred as a set of files, and the only information exchanged during the transfer process is the success or failure of the transfer. In order to get status about the actual job printing, a separate query status (lpq) is sent to the print spooler. Many, if not all, printers with a network interface that supports the TCP/IP protocol support the RFC1179 protocol for job transfer. However, their support for print job status is usually minimal to non-existent. If you want to send a job to a printer using the RFC1179 protocol, please be aware of the following problems. Normally a print spooler (System 5 lp, BSD lpd, LPRng) does not modify a print job when forwarding it to another print spooler. This means that your print job will normally pass from the originating lp or lpr program to the destination printer with no changes. This can have disastrous results if the job requires filter processing. If you are using the LPRng print spooler, job transfers using RFC1179 is specified by using :lp=spoolqueue@host or :rp=spoolqueue:rm=host printcap entries. For example: raw: :lp=raw@host :sh:sf:mx=0 :sd=/var/spool/lp cooked: :rp=cooked:rm=host :sh:sf:mx=0 :sd=/var/spool/lp :filter=/usr/local/libexec/filters/ifhp The raw queue does not have a filter and jobs sent to the raw are transfered intact from the raw queue to the destination raw printer on the host server. Jobs sent to the cooked queue will be processed by the program specified by the filter option. For each data file in the job, the lpd print spooler will open a temporary file to hold the filter output, and then run the filter program with its STDIN set to the job's data file file and the STDOUT set to the temporary file. The filter STDERR will be recorded in an error log. When a job is created a job format may specified (default is f), and an filter can be specified to process job files with this format. The :i<format> option specifies the filter program for use. For example, you can specify a different filter for the n format as shown below. The translate_format option specifies the resulting format for the processed files, and uses a format similar to the UNIX try(1) program. In the example, it specifies that the output of the filter for the n format be renamed as f. cooked: :rp=cooked:rm=host :sh:sf:mx=0 :sd=/var/spool/lp # default filter :filter=/usr/local/libexec/filters/ifhp # n filter :nf=/usr/local/libexec/filters/nfilter :translate_format=nf There is a final option that is used when rather than having a set of job files forwarded to a printer, a single job file is desireable. This is usually the case when sending a job to a host or printer that has a defective RFC1179 spooler implementation, and drops or misprints jobs with multiple files in them. The lpd_bounce option causes the output of all the filters to be put into a single file, and the output is then forwarded to the destination. You can also use the bq_format option to specify the format of the job: cooked: :rp=cooked:rm=host :sh:sf:mx=0 :sd=/var/spool/lp # default filter :filter=/usr/local/libexec/filters/ifhp :lpd_bounce # output has l (literal) or binary output :bq_format=l The lpr -l or lpr -b flag is used to specify the special literal or l job format. Job that have the l format usually have only the most perfunctory processing done by the filter. 4.4. Socket Protocol (TCP/IP) Operation Printcap EntryMany printers with a network interface provide a TCP/IP port that is a direct connection to the internal print engine. If a TCP/IP connection is made to this port and a file is sent over this connection, then the print engine will process the file. More importantly, the connection is bidirectional, and the printer will report errors and status conditions over the connection. PJL and PostScript status request commands can be sent to the printer and the printer will respond with information. The ifhp filter makes extensive use of this protocol, and provides support for status and error reporting. In cooperation with the LPRng print spooler, it will provide a detailed description of the actual print job progress and any error conditions that arise. To use a Socket connection with LPRng, you use the :lp=host%port printcap entry shown below. The lpd print spooler will open a connection to the TCP/IP port on host and passes the (bidirectional) connection to the ifhp filter on file descriptor 1 (STDOUT) and the file to be printed on file descriptor 0 (STDIN). Errors and status information are reported by the ifhp filter on file descriptor 2 (STDOUT) and placed in the error status log by the lpd print spooler. The connection made by the lpd server to the printer is persistent over the entire job; all file transfers for the same job are made over the same connection. This is important as it prevents other printer users from hijacking the printer in the middle of print a job and getting your job outputs mixed together. The following is a typical printcap entry using the socket protocol. 4.5. Appsocket Protocol (TCP/IP) OperationThe Tektronics Phaser Series printers and QMS printers use the Appsocket protocol when sending a job to the printer. This protocol uses two ports: a TCP/IP listening port which accepts TCP/IP connections and a UDP query port that is used to obtain status information. Unfortunately, the UDP port is almost totally useless for job monitoring and status purposes and is not used except in an advisory role. The Appsocket protocol is (briefly):
The Appsocket protocol does not use a persistent connection. If two people are sending jobs to the printer simultaneously it is very likely that the jobs will get intermixed. The appsocket option causes the ifhp filter to open and close a TCP/IP connection to the printer. In order to reopen the device, ifhp needs the device name. It gets this from the PRINTCAP_ENTRY environment variable which has the device information, or by using the TCP/IP address of the initial end of the connection. The following is a sample printcap entry for this printer: # Phaser Setup # Appsocket lp:server :lp=10.0.0.1%9100 :sd=spooldir :... :ifhp=model=ps,appsocket #path to ifhp filter :filter=/.../ifhp For your convenience, the model=phaser entry is suitable for use with the appsocket protocol. 4.6. Common Print Server Boxes Configuration InformationThe following is a list of print server manufacturers, models, and with hints on how to access these boxes with various protocols. Table 4-1. Network Print Servers
All company, brand, and product names are properties of their respective owners. 4.7. Timeout Problems Sending A JobThe ifhp filter may need to run a program such as ghostscript to do format conversion. For large files this can take quite a bit of time and most network printers have a connection timeout. If no data is received for this time the printer will close the connection. By default this timeout is fairly short: 30 or 90 seconds on most printers. If you are sending large jobs to the printer using the socket protocol and are getting timeout problems due to conversion timeouts, then there are two solutions: a) use the Appsocket protocol, which will open and close the connection for each file, and only send data when the converted file is available, or b) do your conversions first and then spool the converted job to be sent directly to the printer. The second method requires an LPRng bounce queue. # Method a) Appsocket lp:server :lp=10.0.0.1%9100 :sd=spooldir :... :ifhp=model=printer,appsocket #path to ifhp filter :filter=/.../ifhp # Method b) Bounce Queue # this queue does the conversion if required lp:server :lpd_bounce :lp=real@localhost :sd=spooldir :... :ifhp=model=printer #path to ifhp filter :filter=/.../ifhp # this queue does transmission real:server :lp=10.0.0.1%9100 :sd=spooldir :ifhp=model=printer #path to ifhp filter :filter=/.../ifhp For method a), the Appsocket protocol is used and the ifhp filter will be invoked before sending a job. For method b), you use two queues: a bounce queue that does the format conversion and then sends the job to the real queue, and the real queue that actually talks to the printer. 4.8. PS, PCL, PJL Printer with TPC/IP Network InterfaceThe most common TCP/IP protocols used for transferring jobs to network printers are RFC 1179, a direct TCP/IP socket, connection to the print engine, and the very odd Appsocket protocol described in previous sections. Here is a reprise of the various printcaps and methods to use them. # printer setup # force clients (lpr, lpq, to use server) lp:lp=lp@serverhost # server information lp:server :sd=spooldir :... # No filtering, transfer using RFC1179, use: :lp=queue@10.1.1.1 # or :rp=queue:rm=10.1.1.1 # Filtering and then transfer using RFC1179, use: :lpd_bounce:lp=queue@10.1.1.1 # or :lpd_bounce:rp=queue:rm=10.1.1.1 :ifhp=model=name :filter=/.../ifhp # Filter, transfer using socket, use: :lp=10.1.1.1%9100 :ifhp=model=name :filter=/.../ifhp # Filter, transfer using Appsocket, use: :lp=10.1.1.1%9100 :ifhp=model=name,appsocket :filter=/.../ifhp If your printer is a parallel port printer connected to an external Network Print Spooler such as an HP JetDirect box, then while the network connection to the Network Print Spooler is bidirectional the connection from the Network Print Spooler to the printer may be unidirectional and no status information will be returned from the Network Print Spooler. In this case you must add the status@ option to tell ifhp not to expect status: 4.9. PS, PCL, PJL Printer with Parallel Port ConnectionIf your printer is connected to a bidirectional parallel port you may be able to read status from the printer. First, determine if your printer has bidirectional IO capability and if your operating system has support for it. If it does not, then do not use the :rw (open connection read-write) option to open the printer device in read write mode. # printer setup # force clients (lpr, lpq, to use server) lp:lp=lp@serverhost # server information lp:server # do now open read write :rw@ :sd=spooldir :... # parallel port :lp=/dev/lpt #path to ifhp filter :filter=/.../ifhp If, on the other hand, your operating system reports that the parallel port is bidirectional and is able to read the printer model information, then you can try opening the parallel port read-write and seeing if the ifhp filter can read status information: # printer setup # force clients (lpr, lpq, to use server) lp:lp=lp@serverhost # server information lp:server # open read write :rw :sd=spooldir :... # parallel port :lp=/dev/lpt #path to ifhp filter :filter=/.../ifhp 4.10. PS, PCL, PJL Printer with Serial PortIt is strongly advised that serial ports not be used for high speed data transfers. The main problem is trying to configure them in such as way that they do not lose characters due to data overruns or parity errors. LPRng is strongly deprecating support for serial port printers. The LPRng print spooler will open and set the serial line characteristics, and pass the open connection to the ifhp filter. The tty connection must pass all 8 bits with no parity, and should use hardware flow control if at all possible. Unfortunately, the various stty options needed to do this vary from system to system. Also, you may discover that your serial connection does not support hardware flow control. If this is the case, then you will have to use software flow control which is rather unreliable for high speed (over 9600) serial lines due to the timing latencies involved. # printer setup # force clients (lpr, lpq, to use server) lp:lp=lp@serverhost # server information lp:server :sd=spooldir :... # serial port :lp=/dev/ttyxxx :stty=38400 -echo -crmod -raw -oddp -evenp \ ixon pass8 -ixany cbreak crtscts #path to ifhp filter :filter=/.../ifhp 4.11. PostScript Only PrinterThe model=ps entry supports PostScript only printers. # printer setup # force clients (lpr, lpq, to use server) lp:lp=lp@serverhost # server information lp:server :sd=spooldir :... :ifhp=model=ps #path to ifhp filter :filter=/.../ifhp If you have a unidirectional or write only (no status information) connection such as a parallel port you should use: Many PostScript printers recognize the PostScript EOJ marker (Control-D or \004) as an end of PostScript job indication and will perform page eject and other suitable actions. Unfortunately, strictly according to PostScript documentation this character is only allowed in the Serial Port Data Stream, and there are some printers that treat it as an error. In addition, the Control-T character is recognized as a printer status solicitation, and some printers do not return status or recognize it as an error. If your printer does not handle PostScript EOJ (Control-D) at all, set ps_eoj@ to suppress generation of extra Control-D characters by ifhp. If your printer requires a Control-D at the end of the job but fails when they occur at the start of the job, set ps_eoj_at_start@. If the printer requires a Control-D at the start but not at the end, set ps_eoj_at_start@. PCL based printers are not nearly as fussy. However, you may discover that some of them do not correctly handle a PCL EOJ at the start of a job in spite of all examples and documention. Use the pcl_eoj_at_start@ to suppress adding a PCL EOJ (Esc E) command string to the start of a PCL job file. See the section on File Conversion Support for ways to print text and other files on a PostScript printer. 4.12. GhostScriptGenerating a raster image from a PostScript or PCL file in a timely manner requires a high speed processor and substantial amounts of memory. Many of the low cost printers require the user's system to do the raster conversion and the raster file is then transferred to the printer. The file format is usually a subset of PCL. The GhostScript program can process PostScript files and produce raster output for a wide range of devices. The ghostscript pcl_gs printer configurations is used with these printers. See GhostScript Printer for details. 4.13. Tektronics Phaser, QMS, and Appsocket ProtocolThe Tektronics Phaser, QMS Network Printers, and a few others use the Appsocket protocol described in a previous section. The Tektronics (model=phaser) configuration entry has the required options for these printers: The following shows a typical printcap entry: # force clients (lpr, lpq, to use server) lp:lp=lp@serverhost # server information lp:server :sd=spooldir :lp=10.1.1.1%35 :... :ifhp=model=phaser #path to ifhp filter :filter=/.../ifhp Chapter 5. Options and Arguments
The ifhp filter is designed to work with the LPRng print spooler and expects to be passed the standard set of filter options. These have the form: /.../ifhp [-c] [-X option]* accountingfile Example: /.../ifhp -n root -H hostname -P printer -s statusfile acct # - X is any letter except T All of the option letters except T are reserved by the LPRng program to pass information to the filter. For details about the options, please consult the LPRng documentation. 5.1. Command Line OptionsThe most important options that LPRng passes and that ifhp uses are:
Since commas are used to separate options, whitespace is used to separate multiple values for a particular option. You will need to quote this on a command line. For example: The ifhp program first checks to see if the PRINTCAP environment variable is defined. By convention, LPRng will place the printer printcap entry in this variable when it starts the ifhp filter. The printcap :ifhp=options value is extracted and used as the default -T options. After getting the options from the printcap, the -Toptions command line options are appended to the list of -T options. The single letter command line options are also made available to the ifhp programs as shown below: PRINTCAP=lp:ifhp=model=this,status@:... ifhp -n root -h localhost -Tmodel=that,debug=1 Concatenated -T options: model=this,status@,n=root,h=localhost,model=that,debug=1 Resulting -T options: status@,n=root,h=localhost,model=that,debug=1 The -T option list is scanned from left to right, and later option values override earlier ones. The -T option values have priority over values that are obtained from the configuration file and cannot be overridden. There are several options that have important effects on the operation of the ifhp filter. 5.2. General Configuration Options - config, trace, debug
These options are used to control the global operation of the ifhp filter, and are only available from the -T command line options.
5.3. Status Messages
5.4. Printer Status Available - status
The status option indicates that there is a bidirectional connection to the printer, and that status can be obtained from the connection. During initialization the ifhp filter will test the printer connection and determine if it supports reading. If it does not then ifhp will set status@. 5.5. Monitoring Options - sync, waitend, pagecountThe sync, waitend, and pagecount options are ignored if no status is available from the printer. The sync option specifies the method to use to determine if the printer is ready and operational. The waitend option specifies the method used to determine when a print job is finished. The pagecount option specifies the method used to obtain pagecount or status information.
5.6. User -Z Option SupportThe ifhp filter provides a simple way for users to request a particular printer facility or option. The lpr -Zkey=value command causes the lpd print spooler to pass the -Z options on the ifhp command line. The ifhp filter implements these options by first determining if they are allowed, and then using them to select a set of strings that are sent to the printer. Since some options are implement by sending PJL strings to the printer, some by PostScript, and some by PCL commands, the method of specifying and generating them is a bit involved. The following facility is used to control the names and types of user options.
For each option, the actual string or set of strings is specified as follows.
The following user options are predefined in the default ifhp.conf file and are recommended for use.
5.7. Adding User OptionsThe following shows how to add a PJL option to an ifhp.conf file. By convention, the configuration is added to the end of the ifhp.conf file. [ newprinter ] pjl_user_opts += [ screen ] pjl_screen = PJL SCREEN = ON ps_user_opts += [ fuzzy ] ps_fuzzy = <</Fuzzy (\%s{fuzzy})>> setpagedevice In the first example we define the screen option. The lpr -Zscreen option will cause the PJL command PJL SCREEN = ON to be put into the output to the printer. Similarly, lpr -Zfuzzy=5 will cause the PostScript command <</Fuzzy (\%s{fuzzy})>> setpagedevice to be processed and the resulting <</Fuzzy (5)>> setpagedevice command to be sent to the printer. 5.8. Initialization and Setup ControlSeveral options are used during the processing steps discussed in Filter Operation Details to control what setup is done for the printer.
These initialization options are very useful in order to set up information controlling the default format or options for a print job. For example: pcl_init = [ normalpage ] pcl_normalpage=[ letter crlf linewrap portrait clearmargins fixed pitch=10 courier ] When processing a PCL job, normalpage is expanded by searching first for normalpage and then for pcl_normalpage; this in turn results in the expansion of the list of values. For example, pcl_crlf is usually defined as pcl_crlf=\033&k2G, which is the PCL command to translate a New Line (\015) character as a Carriage Return/New Line. The other entries have similar definitions that produce the desired effects. Chapter 6. Configuration FileThis section will cover the ifhp.conf file and the various options and configuration methods used to control the operation of the ifhp filter. 6.1. Configuration File EntriesThe ifhp filter uses a simple text based configuration file, usually /usr/local/etc/ifhp.conf or /etc/ifhp.conf to get a set of configuration values which control its operation. The following sample configuration file segment shows how information is specified. # comment line - first non-blank character is a # #---- DEFAULTS ---- # we first have the default section # - a flag option whose value is 1 on_flag # - a flag option whose value is 0 off_flag@ # - a flag option whose value is a string (single line) # its value will be 'this is a string' strval = this is a string # - a flag option whose value is multiple lines # each additional line starts with whitespace # value is 'this\nis1\na\nstring' longstrval = this is\061 a string # - and a list that gets expanded - # '[ this ] [ is a\nlist ]' -> [ this is a list ] longlist = [ this ] [ is a list ] # we can extend a string. # strval will now be 'this is a string added' strval += added # and we can expand a list # '[ this ] [ is a\nlist ] [ more ]' -> [ this is a list more ] longlist += [ more ] # a printer specific section # ---- PRINTER ---- [ hp hp4* ] # this match model=hp, model=hp4, model=hp4x # override the default onflag@ include /usr/local/etc/ifhp.conf.local [ entry1 ] value [ entry2 ] tc=entry1 6.2. CommentsComments are lines whose first non-whitespace character is #. Use \# if the first non-whitespace character must be #. 6.3. Option SettingSyntax Equivalent To option option=1 option@ option=0 option=val option=[ v1 v2 ... ] value contains all whitespace option=[ v1 up to the next option entry v2 blank lines and comments v3 are not included ] option=v1 v2 v3 If an option's default value is the empty string (''). The ifhp program uses the Perl language convention that this value is equivalent to 0 when used in a numerical context or the empty string when used in a string context. In general when a string is used in an integer context it is converted to a the appropriate numerical type using the standard Perl/C numerical representation and conversion methods. The flag syntax sets the value of flag to the string '1', that is, the string with a 1 value, and flag@ sets it to '0'. The option = value syntax sets the option value to a string. The string can extend across multiple lines. A line starting with a space has its value appended to the previous option with a new line (\n) separator. As shown in the example, the += operator is used to append to a string value. The [ option option ...] syntax is used to specify that the value is a list. Lists are used to specify a list of options which can be flags or string values. Lists have the property of recursive evaluation which means that the individual list items will be further processed during printing. This is discussed later in detail. The include facility is currently deprecated, and may not be implemented in future releases. It will cause the specified file to be read and processed at that point in the configuration file. 6.4. Option UseOptions and their values are used to control printer operation. There are two types of options: those with a predefined or builtin meaning to the ifhp filter and those which have their values sent to the printer when appropriate. The builtin options are listed and their use is explained in later sections. 6.5. List ExpansionThe ifhp filter configures a printer by sending the values of options to the printer or performing built-in operations. An option can have a flag, string, or list value. A LIST value has the form [ v1 v2 ... ]. When a list value is to be sent to the printer each of v1, v2, etc. is expanded in turn and the corresponding string value or builtin action is carried out. If the string value of a term is itself a list, the list will be expanded in turn. Recursive list evaluation will result in an error. The following is an example of list expansion: The option t1 is expanded by expanding p1 and then p2; The expansion of p1 produces "this is", and p2 produces [p3 p4]. This list is then expanded to produce "a" and "test". Some LIST options are used in printer language specific contexts and their values are processed appropriately. For example, pjl_init=[...] specifies a set of initialization operations for PJL printers, and pcl_init=[...] is used to specify the initialization needed for PCL printing. The expansion of the LIST entries is done in the language specific context. For PJL this requires that the output be well formed PJL commands, and for PCL that all whitespace be removed. The context dependent expansion is required because sometimes it is necessary to do operations both using PJL and PCL or PJL and PS combinations to ensure correct printer operation. During expansion the language name and an underscore is prefixed to the list entry name and this is used as the option name during expansion. If the prefixed name is not found then the unprefixed name will be used. For example, suppose that we have: pjl_init=[ initstr test ] pcl_init=[ initstr ] pjl_initstr=@PJL ECHO YES pcl_initstr=\033(*0V test=DONE When PJL initialization is being done and we want string values for the pjl_init LIST, we expand initstr and test in the pjl_ context. First a defined pjl_initstr value will be looked for and then a defined initstr value. Since there is a value of pjl_initstr it will be used. Similarly we will check for pjl_test and test values. Since pjl_test does not have a defined value the test value DONE will be used. When PCL initialization is being done and we want string values for the pcl_init LIST, then we expand initstr in a similar way, resulting in \033(*0V. We can use the list entry [ option=value ] to temporarily specify the value of a variable which is then used during language specific expansion. For example, suppose that we have the following set of definitions: As discussed in the next section, the \%s%lcub;initstr%rcub; will cause the value for the initstr value to be substituted into the pjl_initstr string. How this is done is discussed in the section on String Escape Sequences. 6.6. String Escape SequencesString values have a syntax similar to PERL or C. The \ (escape) character indicates the start of an escape sequence string. This has the syntax:
6.7. Language Context and Value ExpansionThe ifhp filter sends initialization and configuration commands to the printer. Depending on the type of language of a print file (i.e. - PostScript or PCL), different command formats would need to be used to implement different options. For example, to implement a landscape option for a PJL aware printer you would need to send the PJL command @PJL SET ORIENTATION=LANDSCAPE. For a PostScript printer you would need to send a very strange string which would depend on the actual printer mode. Our language context also includes various checks for language specific dependencies. This section refers to material that is discussed in depth in later sections of this document, and on first reading may be a little confusing. However, if you are not aware of some of these restrictions then much of the information in the configuration files may be very confusing. 6.7.1. PJL LanguageA PJL command has the form @PJL OPCODE ..., and PJL commands must be sent as a block before any other commands. In order to assist with this, the ifhp filter provides the following assistance. When expanding a list value, each list entry is expected to form a well formatted PJL command.
6.7.2. PCL LanguageWhen sending PCL initialization strings to a printer, it is essential to send nothing that could cause a printable character to be sent before the actual file contents. Such output could cause the location and positioning of text to be altered in unexpected ways. To avoid this, the following steps are taken when expanding a list in a PCL language context.
6.7.3. PostScript LanguageThe PostScript language processing is very minimal, as there are few problems sending PostScript to a printer.
6.8. Printer EntriesThe ifhp.conf file is divided into printer entries by [ pattern pattern ...] lines. Each pattern is glob matched against the model option value, and if the match is successful then the options on the following lines until the next printer entry header are appended to the specific printer configuration entry. By convention, each configuration file is assumed to start with the header [ default ], and the initial set of lines are used to set default values for the various ifhp options. The algorithm for scanning the configuration files first sets the model value to default, and extracts the default information. It then sets the model value to the user specified value, and rescans the configuration file information. If users need to add or modify the ifhp.conf file, then they should add their entries to the end of the file, and override any default options by specific values in their new entry. To aid with system configuration and maintenance, the distributed ifhp.conf file has the following text at the end of the file: ##### This is the end of the standard ifhp.conf file. ##### Add your local files after this ##### If you want to override some entries, simply change the names to ##### something different, i.e. hp4 hp4.old ##### Here is a script to do this and then append your local file to the ##### end of the ifhp.conf file: ##### ##### #!/bin/sh ##### for i in $* ; do ##### perl -spi.bak -e 's/ $i / $i.orig /g' ifhp.conf ##### done ##### ##### sed -n -e '1,/XXX END XXX/p' ifhp.conf >ifhp.conf.new ##### sed '1,/XXX END XXX/d' ifhp.old >> ifhp.conf.new ##### ##### You can probably improve on this. ##### #### XXX END XXX ##### # user adds new default values here for all printer entries [ default ] # set default value pcl_option= \033test [ mypcl_printer ] # override default value pcl_option= 6.9. Include FacilityThe include filename facility is similar to the standard compiler file inclusion facility. The specified file or list of files separated by commas or whitespace will be substituted for the indicated line. 6.10. tc Entry Inclusion FacilityThe tc=entry facilty is similar to the printcap tc facility used in the LPRng software other places. The specified entry or list of entries separated by commas or whitespace will be substituted for the indicated line. Chapter 7. Filter Operation DetailsThe ifhp filter operates by first reading a configuration file to determine the type of printer it is working with, and then proceeds to carry out operations requested by the values of option variables passed on the command line or found in the configuration files. In normal operation, input is read from STDIN (file descriptor 0) and results written to STDOUT (file descriptor 1). Status reports are written to a status file or optionally to STDERR (file descriptor 2), together with any error messages or diagnostics. In addition to normal operation the filter can run in the OF mode and act as a printer initializer and job terminator. This is discussed in detail in the LPRng documentation. When in the OF mode the two character sequence "\031\001" to the filter. will cause the filter to suspend itself by sending itself a SIGSUSP signal. The print spooler will detect this and then send job files to the same output device. After the files have been transferred the the filter will be restarted with a SIGCONT signal. 7.1. Filter Pseudo-CodeThe details of the filter operations are described in the following pseudo-code. The sections marked with ### are discussed later in this document in detail. /// See: Options, Initialization and Setup ###+++ Initialization and Setup // get ifhp information from PRINTCAP_ENTRY environment variable if( PRINTCAP_ENTRY environment variable has a value ){ split printcap information into printcap fields if( :ifhp=options,options is present in printcap ){ split the options list and place in the Toptions list } } Add the -T command line options to the Toptions list Add the -Z command line options to the Zoptions list foreach option in -Toptions do if( option = "debug=level" ){ set Debuglevel = level; } if( option = "trace" ){ output error and trace on STDERR } if( option = "config=pathlist" ){ set configuration pathlist = pathlist; } if( option = "model=name" and model not set ){ set model = name; } } Read the configuration files from the config file list Prepend each file with a [ default ] header Scan the configuration files for [ default ] entries; later entry values will override earlier ones. Repeat the scan, but this time search for [ model ] entries matching the specified model. Put the command line options and -T options into configuration information, effectively overriding the information from the configuration files. if( appsocket ) { Get the :lp=... entry from the PRINTCAP_ENTRY environment variable if( no information ) { use the getpeername() to get the TCP/IP address of the current connection. } if( no informtion AND no dev=... parameter ) { error! } close connection to printer and set -Tdev= device or IP Address } // open a connection to the printer if required // usually only done when appsocket protocol is used if( device specified using -Tdev=device ){ close(1) // if device is host%port, we open TCP/IP connection fd = open(device); // Note - status opens RW // status@ opens WO dup fd to 1; close fd; } ###--- ###+++ Synchronization and Pagecount if( status returned by printer and sync requested ){ do{ send command and wait for timeout; } while( no response ); if( appsocket ){ close and reopen TCP/IP connection; } } if( status and pagecount requested ){ // pagecount has the form pagecount@ (none), // pagecount=ps, pagecount=pjl, ... if( pagecount=language has value ) do { if( pagecount TRUE ){ set pagecount= pjl or ps depending on availability } if( pagecount = pjl and PJL INFO available ){ send PJL INFO PAGECOUNT command to printer } else if( pagecount = ps ){ send PS program to printer } else { terminate with error; } } while( no pagecount response ); if( appsocket ){ close and reopen TCP/IP connection; } } ###--- ### PJL INITIALIZATION if( PJL enabled ){ language = "pjl_" foreach option in pjl_init=[...] { expand the option using the language value #+++ PJL OPTION ACTIONS +++ if( option in pjl_vars_set=[ ... ] and option not in pjl_vars_except expand "@PJL SET OPTION=\%{option}" output = expanded string value } else { if( option value is a string ){ output = expanded string value; } } // output has the form @PJL COMMAND .... if( COMMAND is in pjl_only=[ ... ] and not in pjl_except=[ ... ] ){ send output to printer } #--- end PJL OPTION ACTIONS } if( !OF_mode ){ foreach option in -Toption=value { if( option in pjl_user_opts ){ #+++ USER PJL OPTIONS // join 'pjl_' and the option name expand 'pjl_' . option // perform PJL actions as above #+++ PJL OPTION ACTIONS +++ .... #-- PJL OPTION ACTIONS +++ #--- USER PJL OPTIONS } } foreach option in -Zoption=value { if( option in pjl_user_opts ){ // perform USER PJL actions as above #+++ USER PJL OPTIONS #--- USER PJL OPTIONS } } } } ###--- PJL INITIALIZATION // language is set to the type of job language // - PS, PCL, TEXT, RAW, UNKNOWN // the first part of the job file is read and the filter takes // a (wimpy) guess at the job file based only on the first couple // of characters; language is be PJL, PS, or TEXT, or RAW // This is the same algorithm as the UNIX FILE utility language = default_language (from configuration); if( command line -c (binary) option present ){ language = RAW; } else if( -Zlanguage=xxx option present ){ language=xxx } else if( forceconversion set ){ use UNIX file utility to get file type } else if( file is PS file ){ language=PS if( file starts with PS EOJ (CTRL-D) and ps_eoj_at_start is clear ){ remove the PS EOJ } else { send a PS EOJ first } } else if( file is PCL file ){ language=PCL if( file starts with PCL EOJ (ESC E) and pcl_eoj_at_start is clear ){ remove the PCL EOJ } } if( file conversion table specified then ){ look up file type in conversion table; if( conversion program specified ){ run input through conversion program } set file type to output type } if( language = TEXT and PCL allowed ){ language = PCL; } if( language not recognized by printer ){ exit with error; } if( PJL ENTER supported ){ use PJL ENTER command to select language; send nullpad NULLS to force full buffer condition } // LANGUAGE SPECIFIC INITIALIZATIONS if( language = PCL ){ foreach option in pcl_init { ###+++ expansion do expansion similar to PJL OPTION actions using "pcl_" prefix for option lookup; ###--- } if( not in OF_MODE ){ foreach option in -Toption do { if( option in pcl_user_vars=[ ... ] ){ ###+++ expansion as above ###--- } foreach option in -Zoption do { if( option in pcl_user_opts=[ ... ] ){ ###+++ expansion as above ###--- } } remove whitespace and expand string results; } else if( language = PS ){ ###+++ language specific actions as above, using the ps_ prefix for lookup allow only user option in the ps_user_opts list expand string results but do not remove whitespace } Transfer job to printer, reading error and other information back from the printer if enabled if( language = PCL ){ send PCL End of Job } else if( language = PS ){ send PS End of Job } // job termination ###+++ Synchronization and Pagecount as above finished = 0 while( waitend and not finished ){ // timeouts and retries are done here if( time taken is too long ){ give up and report an error } if( waitend with PJL ){ wait for end of job using UINFO; } else if( waitend with PS ){ send PostScript echo program to printer if end_ctrl_t then add ^T } wait for response if( response has end of job indication ) { finished = 1; } } if( pagecount ){ if( appsocket ){ close and reopen connection; } get pagecount using previously described algorithm } ###--- exit 7.2. Options, Initialization and SetupDuring the setup step, the ifhp system will extract command line options and scan configuration files for printer entries. These operations are covered in detail in other sections. 7.3. Languages Supported- pjl, pcl, ps, and text
These flags set the languages that are recognized or processed by the filter. 7.3.1. pjl_job FLAG
If PJL is enabled and the pjl_job flag is SET a PJL JOB and PJL EOJ command will be generated and sent to the printer at the job start and end respectively. The JOB command has the form: The START and END values can be specified by -Zstartpage=nnn and -Zendpage=mmm command line options. The EOJ command has must match the JOB command.7.3.2. pjl_enter FLAG
If PJL is enabled and the pjl_enter flag is SET, a PJL ENTER LANGUAGE = xx command will be generated when PCL or PS files are sent to the printer. 7.3.3. remove_pjl_at_start FLAG
Some printer drivers will prepend PJL code to the begining of print jobs. If the remove_pjl_at_start flag is SET, ifhp will remove this PJL code. 7.3.4. nullpad STRING
Some older model HP printers require receiving a large number of NULL (0) characters to force commands in the input buffer to be read. This can be done using the nullpad option. In practice, this has turned out to be largely irrelevant as most newer printers and network interface printers do not have this problem. 7.3.5. pjl_console FLAG
When this flag is set and PJL is available and the PJL RDYMSG command is supported, then a short message will be put on the console. 7.3.6. remove_ctrl STRING
The remove_ctrl string option species a list of (control) characters that will be removed from PostScript jobs. This solves the problem of jobs with embedded Control-T or Control-C characters causing abnormal printer operation. For example: would cause Control-C and Control-T characters to be removed.7.3.7. tbcp FLAG
The tbcp flag can be specified as a user option as well as a configuration file option. If the file type is PostScript and this flag is set then the file is transferred using the Transparent Binary Communication Protocol. (See the Adobe PostScript Language Reference Manual for details on the protocol.) At the start of the PostScript job, the sequence \001 M is sent. Afterwards, all control characters in the set 0x01, 0x03, 0x04, 0x05, 0x11, 0x13, 0x14, 0x1C, are replaced by the two character sequence \001 X+'@' or X+'\100' or is sent. For example: 7.4. Synchronization and Pagecounts
Many printers are able to provide status information back to the filter. It is assumed that in these circumstances file descriptor 1 (FD1) is bidirectional and status information can be read from it. When the status option is TRUE, FD1 is readable and is a device or communications socket, then the filter assumes that it can read FD1. Synchronization is usually done in order to ensure that a previously spooled job or printer action has completed correctly, and the printer is ready to accept a new job. It is usually carried out by sending a request to the printer to echo a string back to the filter. Clearly, if the printer cannot provide status or echo values back, then synchronization is impossible. The value of the sync option determines if a PJL ECHO command or simple PostScript program is used. The PostScript program has the form: where TODSTR is replaced with the current Time of Day.To control obtaining synchronization, the sync_interval=nnn and sync_timeout=nnn options are used. The PJL or PS command is repeated at sync_interval=nnn second intervals; if nnn is 0, then it is sent only once. If synchronization is not obtained within sync_timeout=nnn seconds, then the filter exits with an error status. A 0 value or sync_timeout@ disables timeouts. When the ifhp filter is operating in OF mode and the wait_for_banner option is true, the filter will wait until it determines that the banner page has been completely printed before carrying out other filter functions. Pagecounts are used to do accounting and report the number of pages used for a job. Most printers have a hardware based pagecounter mechanism whose value can be read by the appropriate PJL command or PostScript program. For example, if the PJL INFO command is supported by a printer, the printer will return a status message containing the current pagecounter value. Printers that support PostScript may also be able to access the pagecounter value using a PostScript program. The exact details of the PostScript program vary from vendor to vendor and the pagecount_ps_code=... option specifies the PostScript program to use. For example:pagecount_ps_code= /p {print} def ( %%[ pagecount: ) p statusdict begin pagecount end 20 string cvs p ( ]%% ) p () = flush The lpd print server and the ifhp filter must act in coordination to do reliable pagecounting. The following options are used by the ifhp filter to assist with this:
The following options are used in the LPRng printcap entry to assist with getting the pagecounter values: lp: # run at job start :as=/.../accounting_at_start # run at job end :ae=/.../accounting_at_end # -a filter option value or last command line argument :af=/.../acct # default filter :filter=/.../ifhp # of filter - run before and after job, can be suspended # desperation flag for desperate situations #:suspend_of_filter@ :of=/.../ifhp #options :ifhp=...,of_options=pagecount waitend The :as program is run at the start of a print job, and is used to determine if the user has sufficient resourses to print a job. The :ae program is run at the end of a print job and is used to collect the accounting statistics. The ifhp filter will write accounting information to the accounting file specified by the command line -a option, or the last command line argument. When both the :of filter and normal filters are used together, the accounting information will be nested as shown. Normal Mode: start '-qProcessID' '-pPagecounter' \ '-tStartTime' '-Pprinter' '-Hhost' '-nuser' '-Raccntinfo' end '-bPages' '-Telapsed' '-qProcessID' '-pPagecounter' '-tEndTime' '-Pprinter' '-Hhost' '-nuser' '-Raccntinfo' \ '-TElapsedTime' OF Mode: filestart '-qProcessID' '-pPagecounter' \ '-tStartTime' '-Pprinter' '-Hhost' '-nuser' '-Raccntinfo' fileend '-bPages' '-Telapsed' '-qProcessID' '-pPagecounter' \ '-tEndTime' '-Pprinter' '-Hhost' '-nuser' '-Raccntinfo' Sample Accounting File Entry: start '-q10699' '-p234' '-t2000-05-24-09:27:47.784' \ -Plp -Hh4.private -npapowell filestart '-q10700' '-p234' '-t2000-05-24-09:27:47.784' \ -Plp -Hh4.private -npapowell fileend '-b0' '-T1' '-q10700' '-p235' '-t2000-05-24-09:27:47.863' \ -Plp -Hh4.private -npapowell end '-b1' '-T1' '-q10699' '-p235' '-t2000-05-24-09:27:47.863' -Plp -Hh4.private -npapowell The format of the information written to the accounting file is controlled by the accounting_info=AHPn ifhp configuration value. If they are present, the specified ifhp command line flags are appended to the end of the standard accounting information. The accounting=... option specfies a program to run at then end of the job. This program has all of the accounting information passed as command line options. The program should exit with a 0 exit code; otherwise the results are undefined. The printcap :suspend_of_filter controls how the lpd spooler manages the of filter. When a file is to be printed normally, a special two character suspend message (\031\001) is written to the filter STDIN. When the ifhp filter detects this string in the input it is required to suspend itself by sending itself a SIGSUSP signal. The :suspend_of_filter@ flag causes the lpd process to close the :of filter rather than suspending it, and to start a new :of filter process when it needs one. This option is used when there can be at most one process communicating with the printer, or when the ifhp filter must totally reinitialize the printer at job end. The pagecount option controls if and how the pagecounter value will be fetched. Currently pagecount=ps (PostScript) and pagecount=pjl (PJL) are supported. The pagecount form will use PJL if it is available; otherwise PostScript if it is available. The pagecount@ suppresses pagecount operation. The pagecount_start and pagecount_end flags control if the pagecounter will be obtained at the start and end of the print job. One of the major problems with getting printcounter values is that the print job must be totally finished or at least have all of its pages run through the paper feed stream when the pagecounter value is reported. Unfortunately, most manufacturers do not provide accurate ways to coordinate the two activities. The waitend option is used to enable the ifhp filter to send special command sequences to the printer which will detect the true end of job, but this may not be possible on many printers. The printcounter_poll=N (default 1) option provides a method to deal with these types of printers. Commands to get the printcounter value are sent to the printer, and repeated at printcap_interval second intervals until the printcounter value has been stable for N readings. The PJL TEOJ (True End Of Job) command has been used with only limited success to force End of Job reporting only when the job has finished. This can be sent to the printer during PJL initialization by specifying it as one of the PJL initialization strings: The of_options are used to modify the actions of the ifhp filter when it is running in OF Mode. The pagecount_start and pagecount_end (both default to TRUE or ON) control if pagecounter values are obtained at the start or end respectively of the job. The pagecount request is sent to the printer every pagecount_interval=nnn second intervals; if nnn is 0, then it is sent only once. If no pagecount value is obtained within pagecount_timeout=nnn seconds then the filter exits with an error. 7.5. PJL Initialization
If a printer supports PJL, the many printer operations can be initiated and controlled using PJL commands. Unfortunately, not all printers support the same set of commands. In addition, not all printers support the same set of operations or options. A PJL command has the form: A PJL variable is set using: The pjl_only=[ ... ], pjl_except=[ ... ], pjl_vars_set=[ ... ], and pjl_vars_except=[ ... ] options are used to control which PJL commands and which PJL variables can be set. The pjl_only variable lists the commands supported by the printer, and the pjl_except lists commands not supported by the printer. Before sending a PJL command, the ifhp filter checks to make sure that the command name is in pjl_only and not in pjl_except. If the tests fail, then tne command is not sent.Similarly, when sending a command to set a PJL variable, the pjl_vars_set and pjl_vars_except lists are checked to determine if the variable name is in pjl_vars_set and not in pjl_except list. If the tests fail, then tne command is not sent. If PJL is enabled, then the following actions are taken.
7.6. File Conversion Support
The lpr -l or lp -b flags indicate that the spooled files are not to be processed by an output filter. The LPRng spooler recognizes this option and passes the -c command line option to suppress any language specific processing for files. However, many PostScript printers cannot handle text files, and produce many hundreds of pages of garbage output if they are sent to the printer without being translated into PostScript, and some printers require language specific setup in order to print PCL, PostScript or text files correctly. The ifhp filter has builtin tests for PJL, PCL, and PostScript files. These tests are almost identical to those used by many printers which do autodetection. If you need to recognize a wider range of file types, you can configure ifhp to use the UNIX file(1) program. Finally, some printers have a very specialized job format that requires conversion to by a rasterizer program. This is handled as detailed in the following sections. 7.6.1. File Type Detection
The ifhp filter has a set of built-in tests to determine if the input job file is PJL, PostScript, and PCL, or (default) text, and flags the file with language types pjl, ps, pcl, and text respectively. You can also use the UNIX file utility utility to determine type as well. The file utility is invoked with it STDIN attached to the file and ifhp uses the information it writes to STDOUT as the raw file type. The ifhp program will convert the output to lowercase, remove multiple whitespace characters, and replace the remaining whitespace characters with underscores _. By default, ifhp will not try to detect binary files, i.e. - files printed with the binary or literal flag (-c command line flag). You can use the forceprocessing flag to cause all files of all types to be processed. ifhp will first try to use its builtin tests and then will use the file utility. You can set the forceconversion flag to force ifhp to only use the file utility. The following shows the information in the ifhp.conf file used to configure the file type detection. ##forceprocessing - check all files for type - default 'no' forceprocessing@ ## default default_language=text ## force only use of file program ## default is to let ifhp try first, then try file forceconversion@ ## file utility path file_util_path=/usr/bin/file - The output of the file utility is converted to lower case and used as the language type for further processing. 7.6.2. Conversion
Once the language type has been determined, the ifhp filter then decides if a conversion program needs to be run and will convert the input file to a required file type. This activity is controlled by the file_output_match table. file_output_match = [ *postscript* ps \%s{ps_converter} *pcl* pcl \%s{pcl_converter} *pjl* pjl \%s{pjl_converter} *printer*job*language* pjl *text* pcl \%s{pcl_converter} *gzip_compressed* filter \%s{gzip_decompresser} ] The format: will cause ifhp to open and read the specified file for the file_output_match table. The file's contents must have the same format as the file_output_match table but without the [ or ] delimiters. The file_match_table is scanned from first to last entry for a glob pattern that matches the file type determined by the ifhp program or the output of the file_util_path program. If no match is found, then the language is set to the default_language value. The output language of the conversion program is set to the second entry. The conversion program will be run with its STDIN set to the input file and its STDOUT used as the converted output. If there is no conversion program then the original file is used and only the language type is modified. The filter language type causes the specified conversion program to be run and then the output of the program to be reprocessed. As shown above, this allows file decompression routines to be used to expand the files. The following are some short samples of what can be done with the conversion facility. # set up GhostScript gs_device=epsonc gs_options=-r1440 gs=/usr/bin/gs gs_converter= [ \%s{gs} -dBATCH -q -sOutputFile=- \ -sDEVICE=\%s{gs_device} \%s{gs_options} - ] # use GhostScript for conversion ps_converter = [ \%{gs_converter} ] text_converter= [/usr/bin/a2ps -q -B -1 -M Letter \ --borders=no -o- \%s{ps_converter} ] gzip_decompresser = [ /usr/bin/gzip -c -d ] [ ghostscript gs ] file_output_match = [ *postscript* ps \%s{ps_converter} *text* pcl \%s{pcl_converter} *gzip_compressed* filter \%s{gzip_decompresser} ] Printcap entry: pr: :ifhp=model=ghostscript,gs_device=laserjet,gs_options=-r300x300 In this example, we have shown a very interesting device - the GhostScript device. We use the gs (GhostScript) program to do the conversion, and specify the gs_device and gs_options values in the printcap entry. There are a few details that should be observed when using this facility.
The enscript program will exit with a non-zero error codes even for successful conversions and we need to use a wrapper script that will run it and then return the correct error code as shown below. #!/bin/sh # /usr.../wrapper path [options] # wrapper script for a2ps, enscript and others # path is the path to the program and options are the # options to pass. The program is run and then the exit # code is corrected "$@" status=$? case "$status" in 1 ) exit $status ;; esac exit 0 7.6.3. LF to CR/LF Conversion
When processing text or pcl files, the crlf option will enable translation of LF (\n) to CR/LF (\r\n) sequences. If you are using ifhp to simply do LF to CR/LF translation, then you can use: 7.6.4. Text Treated Like PCLText is simply PCL with no special formatting codes. However, you will still need to send the PCL initialization strings to the printer. You can do this by using the following entry in the file_output_match table: 7.6.5. Default to PassthroughYour printer may be capable of handling a wide variety of job formats. If you want to simply pass through files of unknown type or language then use the following entry in the file_output_match table: 7.7. GhostScript PrinterGenerating a raster image from a PostScript or PCL file in a timely manner requires a high speed processor and substantial amounts of memory. Many of the low cost printers require the user's system to do the raster conversion, and a raster file is then transferred to the printer. These files are usually in a proprietary format. The GhostScript program can process PostScript files and produce raster output for a wide range of devices. See the GhostScript documentation for details. Some printers have PCL support but do not support PostScript. The gs and pcl_gs printer configuration support these printers. # PRINTER ghostscript - Printer with GhostScript conversion to raster files gs_converter= [ /usr/bin/gs -dSAFER -dBATCH -q -sOutputFile=- -sDEVICE=\%s{gs_device} \%s{gs_options} - ] text_converter= [ /usr/bin/a2ps -q -B -1 -M Letter --borders=no -o- ] [ ghostscript gs ] pcl@ pjl@ ps text@ file_output_match = [ # PostScript to Raster *postscript* raw \%s{gs_converter} # text to PostScript to Raster conversion *text* filter \%s{text_converter} ] # PRINTER pcl_gs - PCL Printer with GhostScript conversion to raster files [ pcl_gs ] pcl pjl@ ps text@ file_output_match = [ # PostScript to Raster *postscript* raw \%s{gs_converter} *pcl* pcl # text to PostScript to Raster conversion *text* filter \%s{text_converter} ] The \%s{gs_device} and \%s{gs_options} parameters can now be specified in the printcap. The following shows a typical printcap entry for use with this entry. # force clients (lpr, lpq, to use server) lp:lp=lp@serverhost # server information lp:server :sd=spooldir :lp=/dev/lpt0 :... :ifhp=model=gs,gs_device=epson,gs_options=-r240x72 #path to ifhp filter :filter=/.../ifhp The ifhp configuration entry uses GhostScript to do the rasterization of the PostScript file, and the a2ps program to do a text to PostScript conversion. 7.8. Language Specific Initialization
After determining the output file language type, language specific operations are then carried out by expanding the language_init=[ ... ] options in the language context, and then the options in the -Toption=value and -Zoption=value command line options. The -T options are expanded before the -Z, allowing the -Z actions to override any set by the -T actions. As mentioned elsewhere, the reason for the language specific processing is to allow different actions for the same command line option, depending on the file type that is being processed. For example, when processing a PCL file it might be necessary to send PCL command strings and when processing a PostScript file, you would need to send PostScript commands. 7.9. File Transfer and Error Status Monitoring
If the printer can return status, i.e., the status option is on, the filter will read status information from the printer. If the logall flag is SET, then all error messages will be written to the status or log file. If the printer is returning PJL status information, then this has a specific format: The ifhp program will extract the CODE and job start and end flags, and log these as appropriate. Unfortunately, some PJL based printers are extremely verbose in their generation of status messages. In order to reduce the amount of logging of redundant information, ifhp will only record when a device status has changed, rather than when it has been reported. The pjl_quiet_codes=[ code code code ] value is used to suppress reporting of selected error codes. If the error code is in the pjl_quiet_codes list, then the error status will not be reported to the user unless the logall option is set. The list of values is used as glob patterns. For example: Also, there may be error codes which do not have a builtin error message available. New messages can be added using the pjl_error_codes option. Its value is a list of lines, each line consisting of an error code followed by the corresponding error message: pjl_error_codes=[ code=msg code=msg ... ] Example: pjl_error_codes=[ 10000=powersave mode 10001=Ready Online 10002=Ready Offline 10003=Warming Up 10004=Self Test 10005=Reset ] Finally, there are codes or classes of codes that require operator intervention. These are specified using the pjl_alert_codes, and the pjl_alert_handler program will be invoked to send them to the appropriate destination. The formated error message will be available on STDIN for the handler. For example: 7.10. End of Job
The waitend option controls the job termination sequence. By default, this will do the same work as the sync operation, and the option takes the same set of values. If waitend is suppressed using waitend@, then as soon as a job has been transferred, the next step, pagecount, will be attempted. If the print job has not finished at this point, then erroneous page counts will be reported. When the appsocket protocol is used, suppressing waitend will cause no error messages from the printer to be reported. Some printers do not have a True End Of Job reporting capability using PJL. This means that the job will be reported as done, but paper is still moving through the print engine. If you try to get pagecounts at this point you will get the wrong value. An alternative method is to set waitend=ps and The end_ctrl_t=word:word:... This will cause a CONTROL-T to be sent to the printer, a PostScript convention that will cause the PostScript interpreter to return the actual printing status. In most printers this will be printing or something other than idle or busy as long as paper is moving in the print engine. When status is returned, the words in the end_ctrl_t=word:word:... list value are examined for a match. If the status word is present then the end of job condition is assumed. The waitend_interval value controls how often the waitend operation is repeated. This is usually set to a fairly large value, as it is normally used only to recover from printer failures such as users turning the printer on and off. The waitend_ctrl_t_interval controls how often the printer is queried for status using CTRL-T and is usually set to a short (2 or 3 second) value. 7.11. Tektronix Phaser, QMS and AppSocket Support
The appsocket flag is used to specify that data transfer will be done using the AppSocket protocol. The ifhp filter will open a connection to the ip address and port specified by the dev=host%port option and carry out the various operations that it needs to do. Normally after sending information to the printer a close() operation is done on the network connection. This will usually be acceptible as the printer will print the job that was sent to it. However, some printers require that the network connection be left open to report status. If page count information is needed, the ifhp filter will then reopen the connection and get the page count information. Chapter 8. Banners and OF Mode OperationOne of the more difficult administrative issues is whether to print banners (job separators) or to save the large amount of wasted paper, time and effort. The LPRng and ifhp combination provide a rather esoteric set of methods to generate banners, at least one of which should be suitable for your application. You should be aware that some printers have the obnoxious habit of generating their own banner pages when jobs are transferred via the RFC1179 protocol. You should consult the manufacturers documentation and take the necessary steps to turn printer banner page generation off. It may turn out that this is impossible to do, and in that case the only option is to use the Socket or Appsocket connection methods. In the original BSD print spooler, the :of print filter was responsible for banner generation. The print server would send it a magic string that the filter would recognize as a print a banner request, and it would then generate a banner. After this, another special magic cookie string, the character sequence 0x19,0x01, was sent to cause the :of filter to suspend itself. This allowed the print spooler to hold the connection to the printer open while it started another filter to transfer a file. Finally, after all the jobs were sent, the :of filter was sent a SIGCONT signal to wake up and perform whatever closing operations were necessary. This mixing of functionality causes horrible problems when special setup strings must be sent to printers in order to configure them for various operation. In order to avoid these problems, the banner printing and filter functions have been separated in the ifhp filter. If a banner is needed, then LPRng will use a special banner generating program to generate the banner. The output of this program is then sent to the :of filter, or directly to the printer if there is no :of filter. 8.1. No BannerHere is a typical printcap entry when banner printing is not wanted: The :sh (suppress headers or banners) explicitly disables banner printing, and the lpd server will not even attempt to print a banner. 8.2. Banner Printing and No OF FilterThis printcap entry specifies a banner generator program and and banner generation. There is no :of filter specified, so the banner is sent directly to the printer. In such a case the banner printing program should make sure that it generates output with the appropriate set of initialization strings. The pclbanner, psbanner, and lpbanner programs produce PCL, PostScript, and text banners suitable for a wide range of printers. The code for these banner generators is part of the LPRng distribution. lp: :bp=/.../pclbanner :of=/.../ifhp :filter=/.../ifhp # or :bp=/.../psbanner :of=/.../ifhp :filter=/.../ifhp # or :bp=/.../lpbanner :of=/.../ifhp :filter=/.../ifhp 8.3. Banner Printing With OF FilterFinally, we may want banner printing together with the :of filter. This is usually the case when we need to perform special printer setups or require the ifhp filter to do accounting. In this case we need to make sure that the banner page is counted as part of the job: When invoked as an :of filter, the lpd server passes a -Fo option on the command line, so that the ifhp filter knows what mode it is operating in. 8.4. LPRng Options Controlling Banner PrintingThe lpr -h (no header or banner) option suppresses putting banner name (L line) into the control file. The LPRng :ab (always banner) overrides this, and will print a banner using the user name information. The :sh (suppress header) option will override everything and prevent banners from being generated. Banners are generated by the :bp=/... (banner program) program; different banners at start and end can be generated by using the :bs=/... (banner start) and :be=/... (banner end) options, which override the :bp= option. 8.5. of_options optionThis option, usually used on the command line or in the printcap file as part of the :ifhp information, specifies a set of options to use when the filter is running in OF mode. For example: lp: :ifhp=sync@,pagecount@,waitend@,of_options=sync pagecount waitend :filter=/usr/local/libexec/filtes/ifhp :of=/usr/local/libexec/filtes/ifhp same as: lp: :filter=/usr/local/libexec/filtes/ifhp -Tsync@,pagecount@,waitend@ :of=/usr/local/libexec/filtes/ifhp -Tsync,pagecount,waitend In this printcap entry, the ifhp filter is invoked normally with the sync@, pagecount@ and waitend@ options. This causes it to send jobs as fast as possible to the output device and only monitor the device for error status. The of= entry causes the lpd print spooler to start ifhp in OF mode, and the of_options are used to override the other ones. Chapter 9. Font Download SupportFor historical reasons, there is support for downloading a font or other file to the printer. A large amount of the necessary operations are now in the ifhp.conf file. The font_download built-in option supports downloading as described below. 9.1. PCL Font DownloadingThe following shows the a typical ifhp.conf file which has PCL font downloading enabled. # # Fonts and Font Downloading # fontid is used to set the current font pcl_init=[ ... font ... ] # combination command pcl_font=[ delete_fonts font_id font_download font_primary ] # font control # font_op=0 pcl_font_op=\033*c\%{font_op}F pcl_delete_fonts=\033*c0F font_id=1 pcl_font_id=\033*c\%{font_id}D # set primary font font_primary=1 pcl_font_primary=\033(\%{font_primary}X # font directory pcl_fontdir=/usr/local/lib/fonts #default font file font=c1201b.10 To allow users to download a font and have it set up for PCL use, the pcl_init option should include the font option in an appropriate position in the initialization sequence. As shown above, this will get expanded into the pcl_delete_fonts, pcl_font_id, pcl_font_download (which is has built-in support), and the pcl_font_primary options, which are expanded in order. The pcl_font_download is supported by the builtin operation which will find the pcl_fontdir directory value and a value for the font variable, using values from the -Z and -T and configuration information in that order. If no font value is found, no font will be downloaded. For example: When the pcl_font_download option is expanded, it will generate the pathnames /usr/local/lib/fonts/font1 and /usr/local/lib/fonts/font2, open these files, and send their contents directly to the printer. 9.2. PS Font DownloadingPostScript font downloading is supported in a similar manner to PCL font downloading. # # Fonts and Font Downloading # ps_init=[ ... font ... ] # combination command ps_font=[ font_download ] # font directory ps_fontdir=/usr/local/lib/fonts #default font file font=font.ps.10 In a similar manner to the PCL font downloading, when the ps_init list is expanded, the ps_font entry will be expanded in turn. If the -Zfont=ZapDingbat.ps is specified, then the /usr/local/lib/fonts/ZapDingbat.sp file will be opened and downloaded to the printer. 9.3. PJL File DownloadingIn a similar manner to the above font downloading, you can specify a configuration or other setup file that should be sent to the printer as part of the PJL setups. The following configuration shows how to set this up. # # PJL Initialization File Downloading # fontid is used to set the current font pjl_init=[ ... setup ... ] setup=initval font=\%s{setup} # setup directory pjl_fontdir=/usr/local/lib/fonts pjl_setup=[ font_download ] The above configuration will cause the value of the setup -Z, -T or configuration option to be used. Chapter 10. Debugging and Problem SolvingIf you are reading this section, then most likely you have had a problem using ifhp with LPRng. Before going any further, please read RFC1179 (BSD or TCP/IP) Job Transfer Printcap Entry, and make sure that your printcap entry has the lpd_bounce flag set. This is the Most Frequently Asked Question and the Most Frequently Provided Answer on the LPRng mailing list. The following section outlines a method to debug problems with the ifhp filter. It will make use of some diagnostic options that are normally not used in a printcap entry. First, let us start with a typical printcap entry and a problem. lw4: :lp=10.0.0.14%9100 :sd=/var/spool/lpd/%P :ifhp=/usr/local/lib/filters/ifhp Command: lpr -Plw4 -V /etc/motd LPR output: sending job 'papowell@h4+223' to lw4@localhost connecting to 'localhost', attempt 1 connected to 'localhost' requesting printer lw4@localhost sending control file 'cfA223h4.private' to lw4@localhost completed sending 'cfA223h4.private' to lw4@localhost sending data file 'dfA223h4.private' to lw4@localhost completed sending 'dfA223h4.private' to lw4@localhost done job 'papowell@h4+223' transfer to lw4@localhost Version LPRng-3.6.14 When trying to print to the print queue, the user discovers that no output comes out of the printer. The immediate suspicion is that the filter is not working. You should make sure that the lpr command is actually sending the job to the print queue. You can then use lpq to discover what happened: # lpq -llll Printer: lw4@h4 'Hp : Laserwriter' Queue: no printable jobs in queue Status: subserver pid 27251 starting at 15:34:09.350 Status: accounting at start at 15:34:09.357 Status: opening device 'h14.private%9100' at 15:34:09.366 Status: printing job 'root@h4+223' at 15:34:09.375 Status: printing data file 'dfA223h4.private', size 3, IF filter 'ifhp' at 15:34:09.376 Status: IF filter finished at 15:34:35.012 Status: printing done 'root@h4+223' at 15:34:35.012 Status: accounting at end at 15:34:35.014 Status: finished 'root@h4+223', status 'JSUCC' at 15:34:35.014 Status: subserver pid 27251 exit status 'JSUCC' at 15:34:35.018 Status: lw4@h4.private: job 'root@h4+223' printed at 15:34:35.020 Status: job 'root@h4+223' removed at 15:34:35.101 Filter_status: accounting at start, pagecount 89696, pages 0 at 15:34:13.304 Filter_status: sending job file at 15:34:13.306 Filter_status: starting transfer at 15:34:13.306 Filter_status: initial job type 'text' at 15:34:13.306 Filter_status: job type 'pcl' at 15:34:13.306 Filter_status: transferring 3 bytes at 15:34:13.308 Filter_status: 100 percent done at 15:34:13.308 Filter_status: finished writing file, cleaning up at 15:34:13.308 Filter_status: sent job file at 15:34:13.308 Filter_status: doing cleanup at 15:34:13.308 Filter_status: getting end using 'pjl job/eoj' at 15:34:13.309 Filter_status: end of job detected at 15:34:33.219 Filter_status: getting pagecount using 'pjl info pagecount' at 15:34:33.219 Filter_status: final pagecount 89697 at 15:34:35.009 Filter_status: accounting at end, pagecount 89697, pages 1 at 15:34:35.010 Filter_status: done at 15:34:35.010 As you can see from the lpq output, the Status section shows the lpd activities and the Filter_status section shows what ifhp is doing. This is the first line of defense - make sure that the information and errors reported here are for the correct filter. If this does not help, then we will start with the basic filter tests and work our way back to the print server. First, you will need a couple of test files. If you have a PostScript printer, find a simple PostScript file - the ellipse.ps file is included in the ifhp distribution in the UTILS directory. You will also need a short text file - /etc/motd is usually handy to use. Create the /tmp/send file with the following contents: #!/bin/sh cp /dev/null /tmp/t /usr/local/libexec/filters/ifhp -Tdev=/tmp/t,trace,debug=1 </etc/motd 2>/tmp/trace This will create the /tmp/t file, run the ifhp filter, and put the trace and debugging information into the /tmp/trace file. Run this command using: Examine the output in /tmp/trace. It will look like: ifhp 15:46:14.402 [27307] main: Debug '1' ifhp 15:46:14.403 [27307] main: dump <NULL> ifhp 15:46:14.403 [27307] main: Model_id '<NULL>' ifhp 15:46:14.440 [27307] main: scanning Raw for default, then model '<NULL>' ifhp 15:46:14.441 [27307] Select_model_info: id 'default', list->count 1940, model->count 0, init 0 ifhp 15:46:14.448 [27307] Dump_line_list: main: Model information - count 156, max 204, list 0x806e000 ifhp 15:46:14.448 [27307] [ 0]='T=dev=/tmp/g,trace,debug=1' ifhp 15:46:14.448 [27307] [ 1]='banner@' ifhp 15:46:14.448 [27307] [ 2]='banner_file=/usr/local/libexec/filters/psbanner.ps' ifhp 15:46:14.448 [27307] [ 3]='converter=' ifhp 15:46:14.448 [27307] [ 4]='debug=1' ifhp 15:46:14.449 [27307] [ 5]='default_language=text' ifhp 15:46:14.449 [27307] [ 6]='dev=/tmp/g' ifhp 15:46:14.449 [27307] [ 7]='duplex_select=1' Most of the information with debug level 1 is simply showing the details of options, command execution, and error status. This will, however, help with the majority of problems. You can now modify the /tmp/send file to better reflect your printer. #!/bin/sh cp /dev/null /tmp/t # substitute your ifhp options here ifhp=model=hp4,status@ /usr/local/libexec/filters/ifhp -Tdev=/tmp/t,trace,debug=1,${ifhp} </etc/motd 2>/tmp/trace If your printer is a network based printer and you are using RFC1179 transfers, then you can use the following lpr command to send the /tmp/t file directly to the printer: This form of the command causes lpr to send the job directly to the printer. If this works correctly then we know that there is no problem with ifhp formatting the file, and that the problem must be with the lpd print spooler. If your printer is network based and uses a socket connection, then you can have ifhp connect to the printer by using the dev=host%port connection option. This is only used for testing or when you want to use the AppSocket protocol. #!/bin/sh # substitute your ifhp options here # this should always work #ifhp=model=hp4,status@ # this does status checking, no pagecount #ifhp=model=hp4,pagecount@ # this does status checking and pagecount #ifhp=model=hp4 /usr/local/libexec/filters/ifhp -Tdev=10.1.1.1%9100,trace,debug=1,${ifhp} </etc/motd 2>/tmp/trace If you have a windowing system, run this command from one window and in another window use the tail -f /tmp/trace command to view status. Most of the time you will discover that the system is failing to print because either the sync, pagecount, or waitidle step of the printing process is not completing correctly. If there is insufficient detail for you to decide the failure mechanism, set debug=3, or even debug=4 and explore what is happening. If you have a parallel port connected printer on /dev/lptxx, then you can simply use cat /tmp/t >/dev/lptxx and see what happens. If this works, then use: #!/bin/sh # substitute your ifhp options here ifhp=model=hp4,status@ /usr/local/libexec/filters/ifhp -Tdev=/dev/lptxxx,trace,debug=1,${ifhp} </etc/motd 2>/tmp/trace If you have a serial port printer, then you can use a similar method for setting up a connection. You will need to use the undocumented stty option to set the speed and other parameters. These are identical to those used by LPRng, so you should have no problems. #!/bin/sh # substitute your ifhp options here # this should always work #ifhp=model=hp4,status@ # this does status checking, no pagecount #ifhp=model=hp4,pagecount@ # this does status checking and pagecount #ifhp="model=hp4,stty= 9600 -parity crtscts raw" stty="9600 -parity crtscts raw" /usr/local/libexec/filters/ifhp -Tdev=/dev/tty00,trace,debug=1,${ifhp},stty=\"${stty}\" </etc/motd 2>/tmp/trace If all this does not help, then subscribe to the LPRng mailing list and ask for help. Appendix A. Index to Options
Table A-1. ifhp.conf - ifhp Options
Appendix B. HP JetDirect Card SupportThe HPJetDirect card or external JetDirect box can be configured through the printer front panel or through a set of network files. Here is a summary of the methods used from UNIX systems, or when you are desperate, to configure the printer. B.1. MicroSoft JetDirect SupportThere is limited support from HP for non-MicroSoft configuration tools. However, the tools that are provided are simple and easy to use, especially for the initial configuration. B.2. TCP/IP AddressYou can set the TCP/IP address from the front panel. Reset the printer and then use the MENU, +-, SELECT keys as follows: MENU -> MIO MENU (use MENU to display MIO MENU) ITEM -> CFG NETWORK=NO* + -> CFG NETWORK=YES ENTER -> CFG NETWORK=YES* ITEM -> TCP/IP=OFF* (use ITEM to display TCP/IP) + -> TCP/IP=ON ENTER -> TCP/IP=ON* ITEM -> CFG TCP/IP=NO* (use ITEM to display TCP/IP) + -> CFG TCP/IP=YES ENTER -> CFG TCP/IP=YES* ITEM -> BOOTP=NO* (Enable BOOTP if you want to - see below) ITEM -> IP BYTE 1=0* This is IP address MSB byte. Use +- keys to change value, and then ENTER to change Use ITEM keys to get IP BYTE=2,3,4 ITEM -> SM BYTE 1=255* This is the subnet mask value Use +- keys to change value, and then ENTER to change Use ITEM keys to get IP BYTE=2,3,4 ITEM -> LG BYTE 1=255* This is the Syslog server (LoGger) IP address Use +- keys to change value, and then ENTER to change Use ITEM keys to get IP BYTE=2,3,4 ITEM -> GW BYTE 1=255* This is the subnet gateway (router) IP address Use +- keys to change value, and then ENTER to change Use ITEM keys to get IP BYTE=2,3,4 ITEM -> TIMEOUT=90 This is the connection timeout value. It puts a limit on time between connections. A value of 10 is reasonable. B.3. Web Server ConfigurationMany of the newer releases of HP JetDirect firmware have a Web Server configuration capability. Unfortunately, the web pages assume that you have JavaScript support for the browser, and not all of the facilities used are supported by all browsers. However the configuration information and pages presented are extremely simple to use and understand. The major problem with the Web Server configuration is that not all of the options can be set through the Web Server pages. B.4. Telnet ConfigurationOnce you have assigned an IP address to the JetDirect Box you can telnet to the box and configure it through a simple command line interface. When you first connect to the box, hit RETURN a couple of times, followed by ? (Question Mark) RETURN and you should get a simple help menu. This help information usually scrolls off a small (25 line) screen so a buffer that allows you to see all of the information is advisable. The major problem with the telnet configuration is that not all of the options can be set through the command line facilties. B.5. BOOTP InformationIf you have a bootp server, you can put this information in the bootptab file. To use this, you must enable the bootp option on the printer. The T144 option specifies a file to be read from the bootp server. This file is read by using the TFTP protocol, and you must have a TFTPD server enabled. Here is a sample bootptab entry. # Example /etc/bootptab: database for bootp server (/etc/bootpd). # Blank lines and lines beginning with '#' are ignored. # # Legend: # # first field -- hostname # (may be full domain name) # # hd -- home directory # bf -- bootfile # cs -- cookie servers # ds -- domain name servers # gw -- gateways # ha -- hardware address # ht -- hardware type # im -- impress servers # ip -- host IP address # lg -- log servers # lp -- LPR servers # ns -- IEN-116 name servers # rl -- resource location protocol servers # sm -- subnet mask # tc -- template host (points to similar host entry) # to -- time offset (seconds) # ts -- time servers # # Be careful about including backslashes where they're needed. Weird (bad) # things can happen when a backslash is omitted where one is intended. # peripheral1: :hn:ht=ether:vm=rfc1048: :ha=08000903212F: :ip=190.40.101.22: :sm=255.255.255.0: :gw=190.40.101.1: :lg=190.40.101.3: :T144="hpnp/peripheral1.cfg": If you are using the T144 option, you will need to create the configuration file. The sample configuration file from the HP Direct distribution is included below. # # Example HP Network Peripheral Interface configuration file # # Comments begin with '#' and end at the end of the line. # Blank lines are ignored. Entries cannot span lines. # Name is the peripheral (or node) name. It is displayed on the peripheral's # self-test page or configuration plot, and when sysName is obtained through # SNMP. This name can be provided in the BOOTP response or can be specified # in the NPI configuration file to prevent the BOOTP response from overflowing # the packet. The domain portion of the name is not necessary because the # peripheral does not perform Domain Name System (DNS) searches. Name is # limited to 64 characters. name: picasso # Location describes the physical location of the peripheral. This is the # value used by the interface for the MIB-II sysLocation object. The default # location is undefined. Only printable ASCII characters are allowed. # Maximum length is 64 characters. location: 1st floor, south wall # Contact is the name of the person who administers or services the peripheral # and may include how to contact this person. It is limited to 64 characters. # This is the value used by the interface for the MIB-II sysContact object. # The default contact is undefined. Only printable ASCII characters are # allowed. Maximum length is 64 characters. contact: Phil, ext 1234 # The host access list contains the list of hosts or networks of hosts # that are allowed to connect to the peripheral. The format is # "allow: netnum [mask]", where netnum is a network number or a host IP # address. Mask is an address mask of bits to apply to the network number # and connecting host's IP address to verify access to the peripheral. # The mask usually matches the network or subnet mask, but this is not # required. If netnum is a host IP address, the mask 255.255.255.255 can # be omitted. Up to ten access list entries are permitted. # to allow all of network 10 to access the peripheral: allow: 10.0.0.0 255.0.0.0 # to allow a single host without specifying the mask: allow: 15.1.2.3 # Idle timeout is the time (in seconds) after which an idle # print data connection is closed. A value of zero disables # the timeout mechanism. The default timeout is 90 seconds. idle-timeout: 120 # A community name is a password that allows SNMP access to MIB values on # the network peripheral. Community names are not highly secure; they are # not encrypted across the network. The get community name determines which # SNMP GetRequests are responded to. By default, the network peripheral # responds to all GetRequests. The get community name is limited to 32 # characters. # # For hpnpstat and hpnpadmin, the community name can be stored in # /usr/lib/hpnp/hpnpsnmp. get-community-name: blue # The set community name is similar to the get community name. The set # community name determines which SNMP SetRequests are responded to. In # addition, SetRequests are only honored if the sending host is on the # host access list. By default, the network peripheral does not respond # to any SetRequests. The set community name is limited to 32 characters. # # The set community name can come from /usr/lib/hpnp/hpnpsnmp # if it is the same as the get community name. We recommend that the # set community name be different from the get community name though. set-community-name: yellow # SNMP traps are asynchronous notifications of some event that has occurred. # SNMP traps are useful only with network management software. Traps are # sent to specific hosts and include a trap community name. Up to four # hosts can be sent SNMP traps. The trap community name is limited to # 32 characters. The default name is public. trap-community-name: red # The SNMP trap destination list specifies systems to which SNMP # traps are sent. Up to four IP addresses are allowed. If no # trap destinations are listed, traps are not sent. trap-dest: 15.1.2.3 trap-dest: 15.2.3.4 # The SNMP authentication trap parameter enables or disables the sending # of SNMP authentication traps. Authentication traps indicate that an SNMP # request was received and the community name check failed. By default, # the parameter is off. authentication-trap: on # The syslog-facility parameter sets the source facility identifier that the # card uses when issuing syslog messages. Other facilities, for example, # include the kernel (LOG_KERN), the mail system (LOG_MAIL), and the spooling # system (LOG_LPR). The card only allows its syslog facility to be configured # to one of the local user values (LOG_LOCAL0 through LOG_LOCAL7). The # selectable option strings, local0 through local7 (configured to LOG_LOCAL0 # through LOG_LOCAL7, respectively) are case insensitive. The default # syslog-facility for the card is LOG_LPR. syslog-facility: local2 # This parameter allows the card to treat hosts on other subnets as if the # hosts were on the card's subnet. This parameter determines the TCP # Maximum Segment Size (MSS) advertised by the card to hosts on other subnets # and affects the card's initial receive-window size. The card will use a # TCP MSS of 1460 bytes for local hosts, and 536 bytes for a non-local host. # The default is off, that is, the card will use the maximum packet sizes # only on the card's configured subnet. # # The configuration utility does not allow access to this parameter. If you # want to configure it, you must manually edit the NPI configuration file # and add it to the bottom of the entry for the network peripheral. subnets-local: on # This parameter affects how the card handles TCP connection requests from # the host. By default, the JetDirect MPS card will accept a TCP connection # even if the peripheral is off-line. If this parameter is set to "on", then # the card will only accept a TCP connection when the peripheral is on-line. old-idle-mode: off B.6. TimeoutsYou should be aware that the idle-timeout value in the configuration file will override the value entered on the control panel of the printer. Also, the @PJL SET TIMEOUT = NNN command will override this value as well. |