7.0 Printing

7.1 CodeBuilder Print Spooling
7.1.1 The Print Spooler Database
7.2 Local Printing
7.2.1 Printing Text Files to a PostScript LaserWriter on AppleTalk
7.2.2 Spooled Printing to an ASCII-Based ImageWriter Connected Directly to a Serial Port
7.3 Selecting an Alternate Printer
7.4 Status and lp Management Programs

7.0 Printing

CodeBuilder supports UNIX-style spooled printing to PostScript LaserWriters on AppleTalk and to ASCII-based ImageWriters on serial ports. These printing capabilities support both UNIX and Macintosh applications. CodeBuilder supports full UNIX print job control, including the management of multiple printers and multiple spooling queues.

7.1 CodeBuilder Print Spooling

Printing in a standard Macintosh environment requires competing for the exclusive use of a printer and waiting for the relatively slow printing process to complete. With CodeBuilder, your Macintosh is able to be more efficient in its printing by becoming a spooling system. In a CodeBuilder spooled system, text that would normally be sent directly to an AppleTalk LaserWriter is instead directed to a client program. The client transfers the data to a spooling area monitored by a spooling server program and returns control to the application. Thus, applications are only required to spend the amount of time it takes to transfer the print data from one disk to the spooling disk before being able to continue. Since CodeBuilder is a multi-tasking system, the server continues to run in the background and feeds the spooled data one file at a time to a designated printer.

The client program in the CodeBuilder print spooling system is lpr(1). The background server program, also known as the print daemon, is lpd(8). Detailed information on both lpr and lpd and other programs used by the CodeBuilder spooling system can be found in the online manual pages, as well as in the document "4.3 BSD Line Printer Spooler Manual" in the System Manager's Manual section on the CodeBuilder CD-ROM.

7.1.1 The Print Spooler Database

The /etc/printcap file (see printcap(5)) is the master database for the CodeBuilder printing system. It describes all printers directly attached to your system, as well as printers accessible across the network. CodeBuilder is shipped with an initial /etc/printcap file which you may need to modify depending on your printing configuration.

7.2 Local Printing

In order to print with a minimum of system configuration, CodeBuilder comes configured for local spooling of print data. With local spooling, a CodeBuilder system acts as both print spooling client and server.

CodeBuilder supports two local print capabilities for UNIX and Macintosh applications:

7.2.1 Printing Text Files to a PostScript LaserWriter on AppleTalk

To use a LaserWriter on AppleTalk, simply select the printer by using the Chooser Desk Accessory. Then use the lp(1) command as follows:
lp <file_name>
lp is a CodeBuilder shell script which invokes pstext(1), generating formatted PostScript output from the text file. The PostScript output is then queued to the spooling area by lpr, where lpd spools the file to the LaserWriter on your AppleTalk network selected by Chooser. This is the default configuration for CodeBuilder. If you are not already running lpd, lp will start it for you. lp will accept pstext options allowing you to control the output format with respect to orientation, headers, fonts, etc.

7.2.2 Spooled Printing to an ASCII-Based ImageWriter Connected Directly to a Serial Port

UNIX files can be printed to an attached ImageWriter or DeskWriter using the UNIX pr(1) command by utilizing the ImageWriter's ASCII text printing capability.

To print to a locally connected ImageWriter, perform the following steps:
  1. Edit the /etc/printcap file and uncomment (remove the pound (#) marks) from the beginning of each line for the ImageWriter entry. The uncommented entry should look like this:
iw|lp|ImageWriter|ImageWriter II:\

NOTE: If you have a locally connected DeskWriter, uncomment the entry starting with dw|lp|DeskWriter:\ instead. The DeskWriter entry differs from the ImageWriter entry in the setting of the serial port speed (baud rate) designated by the :br#<table entry>: field in the entry. Modify this field as necessary to match the baud rate of your DeskWriter according to the following table:

br# entry
DeskWriter Baud Rate
14.4 Kbps
28.8 Kbps
57.6 Kbps
300 bps
600 bps
1200 bps
1800 bps
2400 bps
4800 bps
9600 bps
19.2 Kbps
38.4 Kbps

The default serial port speed setting for DeskWriter entry in /etc/printcap is 57.6K baud.

  1. If the ImageWriter is connected to the printer port, change the line that says lp=/dev/ttyfa to read lp=/dev/ttyfb. If the ImageWriter is connected to the modem (phone) port, skip this step - printcap is already set in this configuration.

  2. Print a UNIX file by using one of the following two commands:
pr <file_name> | lpr -Piw
lpr -Piw <file_name>
The first version will paginate the output; the second version will produce "raw" output.
If lpd is not running, the following error message will appear:
lpr: connect: No such file or directory
jobs queued, but cannot start daemon
In order to start lpd, you must su to root and then start the daemon by giving the command /usr/sbin/lpd. If you print from CodeBuilder frequently, edit the /etc/rc.conf file to start lpd automatically.

NOTES: The ImageWriter is not selected with the Chooser, but with the -P option of the lpr command. The name following -P may be any one of the names listed on the first line of the /etc/printcap entry for the ImageWriter - iw and ImageWriter work equally well in this case. Macintosh files, such as Microsoft Word files with embedded formatting characters, must be printed from their Macintosh application and cannot be printed with an lp, lpr or pr command. Macintosh programs can access the ImageWriter as they normally do via Chooser.

7.3 Selecting an Alternate Printer

Printing involves explicit or implicit selection of a physical printer. To explicitly select a printer you may use the -P option for the lpr command. If no -P option is specified, the lpr program uses the value of the PRINTER shell environment variable (see printenv(1)). If the environment variable does not exist, lpr uses the first printer with the name lp specified in the /etc/printcap file. In the default configuration, this is also the AppleTalk printer selected via Chooser. For environments with multiple printers on AppleTalk, selecting a printer other than the Chooser printer requires an entry in /etc/printcap. A valid entry looks like:
An "at" entry in the /etc/printcap file specifies the AppleTalk name of a printer. An "at" entry must include the complete AppleTalk name, type, and zone designator in standard AppleTalk format (<name>:<type>@<zone>). A '*' may be used to refer to the "local" zone. The colons at the beginning and end of the entry are required to distinguish the entry from other parameters. The above entry designates a LaserWriter with the AppleTalk name mylaser, of type LaserWriter, associated with the local zone. Note the use of the required backslash to escape a colon internal to the specification. If the name field entry is null, the CodeBuilder system will retrieve the name of the printer from the information saved by the Chooser.

7.4 Status and lp Management Programs

The lpq(1) program shows the status of all files from the local system queued for printing, as well as the status of the remote printer. Use lpq to determine the status of each of your print jobs. Each print job has a number. That number is used to manipulate the job with the lprm and lpc commands. The example below shows a file queued for printing.
lp is ready and printing
Rank    Owner     Job  Files           Total Size
active  holmgren  685  standard input  24799 bytes
The lprm(1) command is used to delete already queued print files that you have subsequently decided not to print. Lprm will first look locally for queued files and then contact any remote spooling systems to request that files be deleted. Files are specified by the job numbers obtained from lpq. For example:
lprm 685
Finally, the lpc(8) program is used to perform larger management operations with printers and queues of print jobs. lpc will enable or disable the overall operations of a specific printer, enable or disable the spooling queue of a printer, rearrange the order of jobs in the spooling queue, and find the status of printers, associated spool queues and spooling daemon software.

[ Top of Page ][ 8.0 Programming Environment ][ Table of Contents ]