Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Absolute BSD - The Ultimate Guide To FreeBSD (2002).pdf
Скачиваний:
31
Добавлен:
17.08.2013
Размер:
8.15 Mб
Скачать

Accessing Print Servers

UNIX printing is an arcane matter, mainly because of the vast array of hardware support. The UNIX printing system was originally designed to work on a teletype, which imposed very specific requirements. It has been expanded to handle dot−matrix, character, inkjet, laser, and every other sort of printer, but it suffers from that legacy. If we could start over with the UNIX printing system and only support laser and inkjet printers, life would be much simpler. Unfortunately, we can't.

Lpd

If you are lucky enough to work in a place with a UNIX−based print server, setting up a printer should be very simple. If, on the other hand, you are using a Microsoft print server, things are a little more complicated. To make your life a bit easier, ask your Windows administrator to install Microsoft's Print Services for UNIX package (NT, 2000, and XP).[2]

The standard UNIX print server protocol, lpd (line printer daemon) runs on TCP port 515. (There is also a line printer daemon program, lpd(8).) To see whether a system offers lpd, telnet to the print server on port 515, just as we tested mail and Web servers in earlier chapters. If you can connect, the system is running the line printer daemon. (Don't expect to see anything while making the connection—the line printer protocol is a pain to speak by hand.)

/etc/printcap

Once you know you have an lpd−based print server available, it's time to configure your system to talk to it. The key lies in the file /etc/printcap. Basic print−cap information appears in Chapter 9, but let's look at it in a bit more detail here. Here's a sample printcap file:

...............................................................................................

v lp|SalesPS|ThirdFloorPrinter:\

w:rp=SalesPS:\

x:rm=printserver:\

y:sd=/var/spool/output/lpd:\

z:lf=/var/log/lpd−errs:

...............................................................................................

The first line in this file gives us the printer's name, SalesPS|ThirdFloorPrinter (v). UNIX printers are traditionally called "lp", "lp1", "lp2", and so on; lp is your default printer; thus the SalesPS printer is our default. In this example, the pipe symbol (|) separated other names for the same printer from each other.

The rp entry, SalesPS (w), is the desired printer's name. You'll need to get a list of printer names from your network administrator. If it's a Microsoft print server, you might check the printers that the print server has shared out, which are the available printers. Be sure to choose a printer that supports PostScript, the generic printing protocol. All modern printers use PostScript, and some also support proprietary printing systems. Fortunately, most FreeBSD programs send either PostScript or plain text to printers.

Note Microsoft servers frequently share one printer under several names and use the name to differentiate how the printing is handled. If you find this to be the case, be sure to choose the PostScript version!

482

If you don't know the name of the remote printer, try lp1, AUTO, or PORT1. (Case is important!) While lp1 and PORT1 are generally PostScript, AUTO will try to detect the sort of print job you're sending.

The rm entry (x) is the name of the server. You must be able to ping this server by the name you give here.

The sd entry (y) is where your local printer daemon will store output it is trying to print.

Finally, the lf entry (z) is the printer log file. If you're having trouble printing, check the permissions on the spool directory. It should be owned by root and the daemon group, and have a permissions mode of 755 (see Chapter 7).

If you substitute correct entries for your print server and your printer name, you should be able to use this entry unmodified. You might want to correct the different names, but it's not strictly necessary. (Not doing so might confuse you later, though, when you see a reference to ThirdFloorPrinter somewhere!)

Running a Local Lpd

Once you have a decent−looking printcap entry, you should be able to start your local line printer daemon, lpd(8). This local printer daemon catches print requests made on your local system and sends requests to the remote printer daemon. You can start this at boottime by enabling it in rc.conf.

...............................................................................................

lpd_enable="YES"

...............................................................................................

Alternatively, you could just run lpd as root.

Printer Testing

Test your printer setup with the command lpq(1), which will display your printer setup. If everything works, you should see something like this:

...............................................................................................

# lpq

no entries

#

...............................................................................................

If your printer is actually printing something at the moment, it'll look more like this:

...............................................................................................

# lpq

 

 

 

 

 

lp is ready and printing

 

 

 

Rank

Owner

Job

Files

Total

Size

1st

mwlucas

4

(standard input )

93151

bytes

#

 

 

 

 

 

...............................................................................................

To fine−tune your printer setup, see the /etc/printcap information in Chapter 9.

483