Technical article 110837

OpenServer 5, How do I customize an interface script for an HP JetDirect printer?

OpenServer 5.0.0OpenServer 5.0.2OpenServer 5.0.4OpenServer 5.0.5

Written · Last revised

Problem

I need to customize the interface script(s) for my HP JetDirect printer(s). For example, I need a printer that prints in landscape, one that prints compressed, one that prints italics, and so on. The hpnpcfg utility doesn't have a menu choice for this. How do I do it?

Solution

Print options can be specified as command line options to the lp command, but sometimes administrators want to configure a printer that always prints with a certain set of options. This can be done two different ways:

1. Write a "wrapper script" that supplies the options the user would have to type in at the command line.

2. Create a custom printer (using /usr/lib/hpnp/hpnpcfg). Name it descriptively and customize its interface file.

Solution 1:
First, find which options give the desired print format. For
example, if you want to print compressed text with landscape
orientation, and have the pages arrive in reverse order, your
lp command might look like:
lp -d <printer> -o "cpi=compressed, -y landscape, reverse" <file>

This is copious for a user to type each time. A wrapper script named "lplc" (l for landscape, c for compressed) could be written to allow users to specify only the file-list. Create a file named lplc in a directory that is likely to be in a user's PATH variable (for example, /usr/bin) and add the following lines:

#!/bin/sh
lp -d <printer> -o "cpi=compressed, -y landscape, reverse" "$*"

Save and exit the file, and then make the permissions 755:

# chmod 755 /usr/bin/lplc
Solution 2:
Create a printer using /usr/lib/hpnp/hpnpcfg and then customize
an HP JetDirect interface script for that printer. This is done
by directly editing the interface file for the printer.  For
example, a printer called hplj4e might print to the hplj4 printer
in expanded format.

For information on configuring HP JetDirect printers, see ta110358, "How do I configure printing to an HP JetDirect Printer or HP Print Server under UnixWare 7?" or your SCO documentation.

The printer's interface file is created as part of the configuration process. You can now customize the way the printer prints by making changes to the interface file. Using our example from above, the interface file would be:

/usr/spool/lp/admins/lp/interfaces/model.orig/hplj4e

Some of the options that can be customized are:

page length, font size and style, lines per page, landscape or portrait orientation, banner, nobanner, characters per inch

The interface file contains comments and instructions that describe the purpose of each setting and how to change it.

For the hplj4e printer, in our example above, edit the file /usr/spool/lp/admins/lp/interfaces/model.orig/hplj4e and change the line:

pitch="def"
to:
pitch="e"

Again, the comments section at the beginning of the interface script provides instruction for other customizations.

NOTE:     Be sure the command line options are used with a printer whose
          filter file (interface script) can handle them. Otherwise, the
          print request will be rejected.

From the Xinuos technical article database, record 110837. Reproduced with permission. The original is at www.sco.com/ta/110837, which is reachable but blocked from search engines. Xinuos marks this article against a retired product line. That refers to the product’s lifecycle, not to whether the advice still works — plenty of it still applies to running systems.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.