Printing in Interix/Services for Unix 3.0

Operating System
Interix Technical Note

Abstract

Printing on an Interix system is handled through the lp command. This paper explains how to set up, test, share, and use printers in Interix.

On This Page

Printing in Interix Printing in Interix
For More Information For More Information

Printing in Interix

Printing on an Interix system is handled through the lp command. The lp command is a shell script that calls the Win32®-based command-line program, print.exe. If you can print a file using print.exe at an NT command prompt, you can print a file using lp.

Throughout this paper, we'll assume you're working with a printer with the share name "Crayon" on the printer "Scribbler".

To print files with the Interix lp command:

  1. Set up the printer so that the Win32 print.exe command can print files.

  2. Set the destination printer for lp, either by using the -d option to lp or by setting it as an environment variable.

Setting Up Your Printer

The first step is to ensure that your printer can print in the Win32 environment using the print.exe command.

Note: The instructions in this section are based on the Windows NT® 4.0 or Windows 2000 operating system. If it conflicts with the documentation for your system, follow your system documentation instead.

  • If the printer is attached to your machine or you are the system administrator responsible for installing the printer, read Setting Up A Printer.

  • If you're responsible for making the printer available to other machines on the network, read Sharing Your Printer.

  • If the printer is on another machine on the network and already prints, read Connecting to a Shared Printer.

Setting Up A Printer

To set up a printer that is attached to your machine, use the Add Printer Wizard accessible from the Control Panel.

You do not need to make this printer the default printer for your system, though you can if you want. The default printer for lp is determined by the value of the PRINTER or LPDEST environment variables in the Interix environment.

If other users on the network are also going to print using your printer, you will need to share the printer. See the instructions in the next section.

Sharing Your Printer

First, see if your printer is currently shared. From an NT console window, you can use the command **net view \\**machinename, where the machinename is the name of the computer connected to the printer. For example, to see which resources are shared by the machine "Scribbler":

net view \\Scribbler
Share name   Type         Used as  Comment
--------------------------------------------------------
ADDRESS      Disk
CDROM        Disk
hp-5mp       Print        LPT1     HP LaserJet 5P/5MP
The command completed successfully.

The type "Print" indicates a printer. If you don't see a printer, then the machine is not sharing the printer with the rest of the network.

To share a printer, you'll need the appropriate permissions.

  1. Click the My Computer icon.

  2. Open the Printers folder.

  3. Select the printer, which has already been configured to work with Windows NT/Windows 2000.

  4. Right-click the printer and select Properties.

  5. Select the Sharing tab.

  6. Click the Shared radio button.

  7. Enter a share name for the printer in the "Share Name" field. For the example printer, enter "Crayon".

  8. Click OK.

Connecting to a Shared Printer

If the printer is already shared from another computer, you simply need to set it up for your system.

  1. Open the Network Neighborhood" and find the computer that shares the printer.

  2. Find the computer that shares the printer and double-click on it.

  3. Double-click on the Printers folder.

  4. From the File menu, click Install.

Testing the Setup

To test, open a Windows NT/Windows 2000 console window (by selecting Start | Programs | Command Prompt), and try to print a file using the print.exe command. For example, to print the file testfile.txt using the printer connected to LPT1 on your machine:

C:\> print testfile.txt
C:\testfile.txt is currently being printed

To print the file testfile.txt using the printer with the share-name crayon connected to the machine SCRIBBLER:

C:\> print /d:\\SCRIBBLER\crayon testfile.txt
C:\testfile.txt is currently being printed

If you can print to a printer using a Win32-based application (such as Word), you should be able to print to that printer using print.exe.

Specifying a Printer

There are two ways to specify a printer with the lp command.

  • To specify the printer for a single command, use the -d option.

  • To specify the default printer, set the LPDEST environment variable or PRINTER environment variable.

The -d Option

The -d option to lp specifies the printer. Since the argument to -d is passed to the print.exe command, it has to be in UNC format, a form that print.exe understands, \\MACHINE\sharename. The backslashes must be escaped to prevent interpretation by the shell.

Both of these lp commands print the file testfile.txt on the printer with the UNC name \\SCRIBBLER\crayon***:***

lp -d \\\\SCRIBBLER\\crayon testfile.txt
lp -d `\\SCRIBBLER\crayon' testfile.txt

If the printer is attached to your machine, you can instead specify the printing port:

lp -d lpt1: testfile.txt
lp -d lpt2: testfile.txt

The Environment Variables

If no printer is specified on the command line, the lp command checks the value of the environment variable LPDEST. If LPDEST isn't set, the lp command uses the value of the environment variable PRINTER.

For our example, we'll assume you're setting LPDEST. This value is passed to print.exe, so it must be in UNC format, escaped for the shell.

In the KornShell, you can make crayon your default printer with this command:

export PRINTER=\\\\SCRIBBLER\\crayon

In the C shell:

setenv PRINTER \\\\SCRIBBLER\\crayon

Specifying Print.exe

By default, the lp script uses the version of print.exe found in %WINDIR%/system32. If you need to specify an alternate version of print.exe, use the environment variable LP_PRINT. The pathname is in Interix format, not Win32 format.

For example, if the Win32 print.exe command you want to use is installed as D:\alternate\print32.exe, set the LP_PRINT environment variable with either of these commands:

export LP_PRINT=//D/alternate/print32.exe
setenv LP_PRINT //D/alternate/print32.exe

Since the lp command is written specifically for the Windows NT/Windows 2000 print.exe command, this feature is only useful on systems where you have multiple versions of Windows NT or Windows 2000 installed.

Adjusting the Print Queue

To remove jobs from the print queue or to change priorities, open the Windows NT/Windows 2000 printer box for that printer.

  1. From the Start menu, select Settings | Printers and then select the printer. (If you have only one printer active, you can also select the small printer icon near the clock in the task bar, which is displayed while the job is queued.)

  2. To delete a job, select it in the display and press the Delete key.

Other Printing Services on Windows NT/Windows 2000

There are other printing services available on Windows NT/Windows 2000, but they do not work with the Interix lp program. They are intended to allow Windows NT– or Windows 2000–based machines to share printing services over a heterogeneous network. The other machines are presumed to be running an open systems operating system such as Linux, BSD, or SVR4.

lpr

A Win32 print spooler. The lpr command sends print jobs from your Windows NT– or Windows 2000–based machine to an open systems machine running a line

printer daemon (lpd). The Microsoft TCP/IP Printing service must
be installed before this will work.

lpq

A Win32-based program to view the status of a remote lpd queue.

lpdsvc

A Windows NT/Windows 2000 service which prints jobs coming from a client on an open systems machine.

For More Information

For more information about Interix, see the Interix Web site at:
https://www.microsoft.com/windows2000/interix.