# TCP/IP DOS Utilities #### Printing Files on Remote Printers Part 5/9

Previous: Transferring Files Next: Executing Commands on a Remote Host

## Printing Files on Remote Printers

The LAN WorkPlace® utilities include two groups of utilities for printing your DOS files on a printer connected to a remote host: the L printing utilities and the R printing utilities.

The L printing utilities are easier to set up and provide more system security. For these reasons, most users should use the L printing utilities. System administrators and users who have the RSH server instead of the LPD server should use the R printing utilities.

The following table introduces the printing utilities.

Description of Printing Utilities

L-Utility | R-Utility | Description LPR | RPR | These utilities send print jobs to a remote printer.
LPQ | RPS | These utilities check the status of print jobs in a remote printer queue.
LPRM | RPD | These utilities delete print jobs from a remote printer queue.

### Setting Up the Printer Utilities

If you want to use the L printing utilities, your workstation and remote host must meet the following requirements:

- The line printer daemon (LPD server) must be running on the remote host to which the printer is connected.
- Your workstation name must be included in the /etc/hosts.lpd file (or the equivalent for non-UNIX® hosts) on the host machine running the LPD server. See your system administrator to add your workstation to this file.
- Your username must be included in the NAME environment on your workstation.
- Your username is established here with the SET NAME command, entered either by you or your LANWP.BAT file.
- There should be a printer configuration file (PRINT.CFG) in the \NET\HSTACC directory on your workstation.

The L printing utilities reference this file for printer and host names when you omit these command-line parameters. If the L printing utilities need this information and cannot find a configuration file, they display an error message and stop execution.

See "Setting Up a Printer Configuration File" to set up this file in your \NET\HSTACC directory.

If you want to use the R printing utilities, your workstation and remote host must meet the following requirements:

- The RSH server must be running on the remote host to which the printer is connected.
- Your workstation name must be included in the /etc/hosts file (or the equivalent for non-UNIX hosts) on the host machine running the RSH server. See your system administrator to add your workstation to this file.
- The remote host must be listed in the DNS name server or the HOSTS file in the \NET\TCP directory on your workstation.

  Your hostname must be spelled exactly as it is spelled in the /etc/hosts file (or the equivalent) on the remote host. You do not need to match uppercase and lowercase letters---these files are not case-sensitive.

- There must be a printer configuration file (PRINT.CFG) in the \NET\HSTACC directory on your workstation.

  The R utilities reference this file to identify the host connected to the printer you specify.

See "Setting Up a Printer Configuration File" to set up this file in the \NET\HSTACC directory.

The remote host must authorize access by your workstation in one of the following ways:

- Your workstation and username must be listed in the .rhosts file in the home directory of the remote account you are accessing.

  If you can access the remote host to update the file, add your workstation name and username in the following format:

  > workstation_name username

  If you cannot update the file, see the system administrator for the remote host to add your workstation and username to this file.

- Your workstation must be listed in the hosts.equiv file.

See the system administrator for the remote host to add your workstation name to this file.

### Sending a File to a Remote Printer

The LPR and RPR utilities enable you to send files to a printer connected to a remote host. The following sections describe how to use these utilities.

#### Printing a File with the LPR Utility

The LPR utility sends files to a printer connected to a remote host running the LPD server. It does this by creating a printer job in a spooling area on the host. The printer prints the job once the printer becomes available.

Use LPR to send files to a remote printer by using the LPR command in the following format:

>     LPR [ -P printer ] [ -H host ] [ -C class ] [ -J job] [ -T title ]
>         [ -# copies ] [ -i [ indent ] ] [ -wcolumns ] [ -h ] [ -q ] [ -p ]
>         [ -l ] [ -v ] [ -f ][ -t ] [ -n ] [ -d ] [ -g ] [ -c ] [ -o ]
>         [ filename [ ... ] ]

L printing utility command-line options and parameters are case-sensitive; they must be entered in uppercase or lowercase, as shown. You can type utility names, such as LPR, in either uppercase or lowercase characters.

The following table describes the LPR command-line options and parameters:

LPR Options and Parameters

Options and Parameters | Description -P printer | This option and parameter specify the printer to which you are sending a print job. This is the ASCII name as it appears in the /etc/printcap file (or the equivalent) on the remote host. By default, LPR uses the first PRINTER: entry in the PRINT.CFG file.
-H host | This option and parameter specify the host to which the printer is connected. The host can be the hostname or the IP address in dotted notation. By default, LPR uses the hostname associated with the first PRINT.CFG PRINTER: entry that matches the printer you specified with the -P option. If you specify neither a host nor a printer, LPR uses the first host and printer in the PRINT.CFG file.
-# copies | This option and parameter specify the number of copies you want to print. By default, LPR prints one copy.
-C class | This option and parameter print class as the job classification on the banner page. The class can be up to 31 characters long. By default, the hostname is the classification.
-J job | This option and parameter print job as the job name on the banner page. By default, job is the first filename you enter.
-T title | This option and parameter use title as the name to print for the UNIX text pagination utility (pr). The title can be up to 79 characters long. This option is available only when you include the -p option, described in this table. By default, the filename is the title.
-i [ indent ] | This option and parameter specify the number of columns by which the printer should indent each line on the printout; this is only applicable with the -p option, described in this table, and is ignored with all other filter options.
-w columns | This option and parameter use columns as the page width for the UNIX pr utility.
-h | This option suppresses printing of the burst page. When the burst page is suppressed, any associated values such as class and job are ignored.
-q | This option activates the quiet mode. This mode suppresses command status reporting.
-p | This option uses the UNIX pr utility to format files for printing.
-l | This option prints files without filtering the control characters.
-v | This option prints files in Sun* raster format.
-f | This option prints files using FORTRAN format; the first column of each line is treated as a FORTRAN carriage control character.
-t | This option prints files as Graphic Systems C/A/T phototypesetter input; C/A/ T is the standard output for the UNIX troff command.
-n | This option prints files as ditroff output, if your printer is configured for this output.
-d | This option prints files in Stanford DVI* format for TeX output, if your printer is configured for this output.
-g | This option prints files that are output from the Berkeley UNIX plot library, if your printer is configured for this output.
-c | This option plots files that are formatted in CalTech Intermediate Format (CIF), if your printer is configured for this output.
-o | This option prints files using PostScript*.
filename [...] | This parameter identifies the files that you want to print. You can include any valid DOS wildcard characters, such as * and ?, in the filename specification. You can specify filename as a complete or partial path name. If you omit filename, LPR reads from standard input (usually the keyboard).

For example, to send the SCHEDULE.DOC file to the LASER1 printer connected to the VENUS host and print a title (ProjectSchedule) on the banner page, type the following command:

>     LPR -P LASER1 -H VENUS -T ProjectSchedule schedule.doc <Enter>

As LPR sends your file to the printer, it displays the following messages:

>     LPR - Copyright (c) 1992, Novell, Inc.Sending schedule.doc to venus.schedule.doc sent.

#### Printing a File with the RPR Utility

The RPR utility sends files to a printer connected to a remote host running the RSH server. Type the RPR command in the following format:

>     RPR [ -A | -B ] [ -L username ] [ -P printer ] [ -Ttitle ]
>         [ filename [ ... ] ]

The following table describes the RPR command-line options and parameters.

RPR Options and Parameters

Options and Parameters | Description -A | This option forces RPR to send filename as an ASCII text file.
-B | This option forces RPR to send filename as a binary file. This option is useful for printing graphic-image files.
-L username | This option and parameter specify the name of the remote user. This is the name of the account through which you can access the remote host. If you omit this option, RPR uses your default remote username, established with the DOS SET NAME command.
-P printer | This option and parameter specify the name of the remote printer you want to use. You must specify printer exactly as it is listed in your printer configuration file, PRINT.CFG. The RPR entry is selected by matching printer to the PRINTER: entries in the printer configuration file. RPR uses the first matching PRINTER: entry to determine the host connected to the printer. If you do not specify this option, RPR uses the first printer entry listed in the PRINT.CFG file.
-T title | This option and parameter specify a title for RPR to print instead of the default TITLE: entry established in PRINT.CFG.
filename [...] | This parameter specifies the name of one or more files you want to print. You can include any valid DOS wildcard characters, such as * and ?, in the filename specification. You can specify filename as a complete or partial path. If you omit filename, RPR reads from standard input (usually the keyboard).

If the remote printer is attached to a UNIX host, RPR typically does not display a response when you send a file to the printer. If the remote printer is attached to a VMS host, RPR displays a message similar to the following:

>     job 936 (queue 3, entry 1) queued

To abort an RPR command, press Ctrl+C <Enter> or Ctrl+Break <Enter>.

### Checking the Status of Print Queues

The LPQ and RPS utilities enable you to check the status of remote print queues.

#### Listing Print Queues with the LPQ Utility

The LPQ utility displays the contents of a print queue. To display the contents of a remote queue, use the LPQ command in the following format:

>     LPQ [ -P printer ] [ -H host ] [ -n ] [ -l ] [ -q ] [job# [ ... ] ]
>         [ username [ ... ] ]

The following table describes the LPQ command-line options and parameters.

LPQ Options and Parameters

Options and Parameters | Description -P printer | This option and parameter specify the print queue for which you need status. This is the ASCII name as it appears in the /etc/printcap file on the host. By default, if you do not specify this parameter, LPQ uses the first PRINTER: entry in the PRINT.CFG file.
-H host | This option and parameter specify the host to which the printer is configured. The host can be a hostname or an IP address in dotted notation. The default for this parameter is the hostname associated with the first PRINTER: entry in the PRINT.CFG file.
-n | This option lists the print queues for LAN WorkPlace print servers on the host you specify with the -H option. This option does not list print queues for UNIX print servers.
-l | This option displays queue information in long format.
-q | This option specifies quiet mode. It suppresses the reporting of LPQ status.
job# [...] | This parameter specifies the job number for which you want to display status. If you include this parameter, type it in digits. By default, job# is all jobs owned by username. You can specify a maximum of 20 job numbers.
username [ ... ] | This parameter specifies usernames for which you want print queue information. If you include this parameter, it must begin with an alpha character. By default, LPQ assumes that the username is all users. You can specify up to five usernames.

For example, to display the queue for the LASER1 printer, which is connected to the VENUS host, type the following command:

>     LPQ -P LASER1 -H VENUS <Enter>

A typical LPQ Queue Status Listing:

>     LPQ - Copyright (c) 1992, Novell, Inc.
>     Querying the print queue for LASER1 on VENUS
>     LASER1 is ready and printing
>     Rank    Owner    Job       Files          Total Size
>     active  evelyn   23       schedule.doc   18323 bytes
>     1st     smith    35       project.doc    10777 bytes

You can display a list of print queues for a host by specifying the host and including the -n option with the LPQ command:

>     LPQ -H hostname -n

A typical list of print queues for a host:

>     Querying host 155.55.5.55 for print queue names.
>     prt1:
>      Printer Type = Apple LaserWriter II NT,pscript
>     prt2:
>      Printer Type = HP LaserJet IIIsi PostScript,pscript
>     prt3:
>      Printer Type = Apple LaserWriter II NT,pscript

#### Listing Print Queues with the RPS Utility

The RPS utility displays the contents of a print queue. To display the contents of a remote print queue, type the RPS command in the following format:

>     RPS [ -P printer ] [ -L username ] [ job_id ]

You can include a job_id if you received one from the remote host when you sent the job to the printer.

The following table describes the RPS command-line options and parameters.

RPS Options and Parameters

Options and Parameters | Description -P printer | This option and parameter specify the remote print queue for which you want status. If you omit this option, RPS selects the first PRINTER: (the default printer) entry listed in your printer configuration file, PRINT.CFG.
-L username | This option and parameter specify the name of the user whose job information you want to display. This is the name of the account through which you are accessing the remote host. If you omit this option, RPS selects the username you or your LANWP.BAT file established with the DOS SET NAME command.
job_id | This parameter specifies the job number of a print job. This option might be required by the remote host to which the printer is attached. The job_id is required if the RPR command returns a job identifier upon completion. You must type the job identifier exactly as it is displayed by RPR.

What status message RPS displays depends on the remote host. If the remote printer is attached to a UNIX host, RPS displays a status message similar to the one shown:

>     laser1 is ready and printing
>     Rank  Owner    Job  Files            Total Size
>     1st   evelyn   936  march.sls         333 bytes
>     2nd   carlyle  937  spin.c         100276 bytes

If the remote printer is attached to a VMS host, RPS displays a status message similar to the following:

>     Printer queue SYS$PRINT, running on $PRINTER,
>     mounted on DEFAULT
>     Job name   Username  Entry  Blocks  Status
>     march.sls  evelyn    161    1       pending
>     spin.c     carlyle   162    10      pending

### Setting Up a Printer Configuration File

Before you can use the RPR utility to print files on a remote printer, there must be a printer configuration file (PRINT.CFG) in the \NET\HSTACC directory on your workstation. This file defines the remote printers and printer hosts RPR can access from your workstation. The entry for each printer includes the printer's name, the remote host to which the printer is attached, print-job control information, and the remote commands to be executed for the RPR, RPS, and RPD utilities.

The L printer utilities also reference the PRINT.CFG file. If you omit the printer and host parameters when using these utilities and there is no PRINT.CFG file in your \NET\HSTACC directory, the L printer utility displays an error message.

The LAN WorkPlace for DOS software includes a sample PRINT.CFG file in the \NET\SAMPLE directory. This file includes generic configurations for printers attached to remote hosts running UNIX 4.2BSD/4.3BSD, UNIX System V.2/V.3, and VMS. You can modify the sample configuration file as described in this chapter and copy it to the \NET\HSTACC directory on your workstation.

The LPR and LPRM utilities take your username from the NAME variable in the DOS environment table. The username is not provided as part of the command line for security reasons. The username is also used for the R utilities.

Each printer configuration uses the keywords listed in the first table below and the command-line modifiers listed in second table below. The keywords identify parameters sent to the host; the modifiers substitute values you type in the command line.

Printer Configuration File Keywords

Keyword | Explanation BREAKCHARS: | This keyword specifies the characters that separate multiple files in a print job. This is usually a form-feed character (0C Hex). You can enter alphanumeric characters for printable characters and hexadecimal values for all characters.
HOST: | This keyword specifies the host to which the remote printer is attached.
PRINTER: | This keyword specifies the name of a printer. It can be any alphanumeric character string. It cannot contain embedded spaces, and all leading and trailing blanks are stripped off. Regardless of how this name is entered in the printer configuration file, it is case-insensitive when you issue an RPR, RPS, or RPD command.
RPD: | This keyword is a command RPD sends to the remote host to delete a job from the printer queue.
RPR: | This keyword is a command RPR sends to the remote host to print a file.
RPS: | This keyword is a command RPS sends to the remote host to determine the status of a print job.
TITLE: | This keyword is the default title of the printer configuration file. It is printed on the banner page in place of the %t variable (see Table 5-7) on the RPR command line. TITLE: must be the first line in the printer configuration file (even if it has no assigned value).

Printer Configuration File Command-Line Modifiers

Command-Line Modifier | Explanation %u | This modifier substitutes the remote username.
%t | This modifier substitutes the title phrase. The TITLE: entry in the printer configuration file, which is the first entry in this file, is used if you do not specify one with the -T option on the command line.
%f | This modifier substitutes the filename from the command line.
%j | This modifier substitutes the job ID from the command line.

You can include a percent sign (%) in a command by preceding it by another percent sign.

The following sections explain the entries for the various system configurations in the sample printer configuration file.

### Printing a Title on Print Jobs

The first line in the printer configuration file defines a title string that is printed on the banner page. To print this title, you must include the %t variable on the RPR: lines that follow the TITLE: line.

TITLE: must be the first line in the printer configuration file. It must be included even if it is blank.

For example, the TITLE: line has the following format:

>     TITLE: default_title_string

You can specify a title by changing default_title_string to the desired text.

>     TITLE: status_reports

To print the title, you must include the %t variable in the RPR: lines.

>     RPR: lpr -Pps -J%f %t

### Printing on a UNIX BSD System

The first set of printer entries in the printer configuration file is for printing text (ASCII) and binary files on a printer attached to a remote host running UNIX 4.2BSD or 4.3BSD. The example below displays these entries. Each of these entries is described by the comment to its right.

>     PRINTER:       4.2BSDprinter        # Printer name
>     HOST:          BSD4.2_host          # Remote hostname
>     BREAKCHARS:    0x0C                 # Remote host form feed character
>     RPR: lpr -Pps -J%f -T%t             # UNIX print command to be executed
>                                         # when RPR command is entered
>     RPS: lpq -Pps -l %u                 # UNIX print queue status command to be
>                                         # executed when RPS command is entered
>     RPD: lprm -Pps %j                   # UNIX print job delete command to be
>                                         # executed when RPD command is entered

### Printing on a UNIX System V System

The second set of entries in the printer configuration file is for printing text (ASCII) and binary files on a printer attached to a remote host running UNIX System V Release 2 or Release 3. This example displays these entries. Each of these entries is explained by the comment to its right.

>     PRINTER:      4.2BSDprinter        # Printer name
>     HOST:         BSD4.2_host          # Remote hostname
>     BREAKCHARS:   0x0C                 # Remote host form feed character
>     RPR: lp -dprinter -t%f             # UNIX print command to be executed
>                                        # when RPR command is entered
>     RPS: lpstat -u%u                   # UNIX print queue status command to be
>                                        # executed when RPS command is entered
>     RPD: cancel %3                     # UNIX print job delete command to be
>                                        # executed when RPD command is entered

### Printing on a VMS System

The third set of entries in the printer configuration file is for printing text (ASCII) files on a printer attached to a remote host running VMS. This example displays these entries. Each of these entries is explained by the comment to its right.

>     PRINTER:      vmsASCII            # Printer name
>     HOST:         VMS_host            # Remote hostname
>     BREAKCHARS:   0x0C                # Remote host form feed character
>     RPR: @exos_etc:printasc %f        # VMS print command to be executed
>                                       # when RPR command is entered
>     RPS: show queue sys$print         # VMS print queue status command to be
>                                       # executed when RPS command is entered
>     RPD: delete/entry=%j sys$print    # VMS print job delete command to be
>                                       # executed when RPD command is entered

The RPR: line in Example 5-7 specifies the EXOS_ETC:PRINTASC.COM filename. This file is a VMS command procedure included with the LAN WorkPlace software in the \NET\SAMPLE directory. It contains the following commands:

> $ exos_name = f $getjpi("","PID")
> $ name = "sys $login:"exos_name'.tmp"
> $ copy sys$command 'name
> $ if ""p1'" .nes. "" then
> $ print/delete/name='p1 'name
> $ if ""p1'" .eqs. "" then
> $ print/delete 'name

The first line assigns the process ID of the print job to the variable exos_name. The second line creates a VMS filename in the format filename.tmp. The third line copies the name of the file specified with RPR to filename.tmp. The fourth line prints and then deletes the file if a job name is specified with the RPR command. The last line prints and then deletes the file if the RPR line does not specify a job name. You can modify this command procedure to meet your specific needs.

The fifth set of entries in the sample printer configuration file is for printing binary files on a printer attached to a remote host running VMS. The example below displays these entries. Each of these entries is explained by a comment to its right.

>     PRINTER:         vmsBINARY      # Printer name
>     HOST:            VMS_host       # Remote hostname
>     BREAKCHARS:      0x0C           # Remote host form feed character
>     RPR: @exos_etc:printbin %f      # VMS print command to be executed
>                                     # when RPR command is entered
>     RPS: show queue sys$print       # VMS print queue status command to be
>                                     # executed when RPS command is entered
>     RPD: delete/entry=%j sys$print  # VMS print job delete command to be
>                                     # executed when RPD command is entered

The RPR line in Example 5-8 specifies the EXOS_ETC:PRINTBIN.COM filename. The PRINTBIN.COM file is a command procedure included with the LAN WorkPlace software in the \NET\SAMPLE directory. It contains the following commands:

> $ exos_name = f$getjpi("","PID")
> $ name = "sys$login:"exos_name'.tmp"
> $ create/fdl=exos_etc:template.fdl 'name
> $ copy sys$command 'name
> $ if ""p1'" .nes. "" then
> $ print/passall/delete/name='p1 'name
> $ if ""p1'" .eqs. "" then
> $ print/passall/delete 'name

The first line assigns the process ID of your print job to the variable exos_name. The second line creates a VMS filename in the format filename.tmp. The third line creates a file definition language file used to print the file. The file TEMPLATE.FDL is a template file definition language file included with the LAN WorkPlace software in the \NET\SAMPLE directory. In this file, ORGANIZATION must be set to sequential, PROTECTION must be set to (system:RWD, owner: RWED, group:R, world:R), CARRIAGE_CONTROL must be set to none, and FORMAT must be set to variable. Refer to the VAX/VMS File Definition Language Manual for more information.

The fourth line copies the name of the file entered with RPR to filename.tmp. The fifth line prints and then deletes the file if a job name is specified with the RPR command. The last line prints and then deletes the file if the RPR line does not specify a job name. You can modify this command procedure to meet your specific needs.

You must specify the PASSALL option to print binary files.

### Deleting Jobs from the Print Queue

The LPRM and RPD utilities enable you to delete a print job from a queue on a remote printer.

#### Deleting Jobs with the LPRM Utility

The LPRM utility removes jobs from a printer spooling queue. Permission to access the spool directory is normally not available to users. LPRM usually provides the only access method to the spooling queue.

If you are authorized to use the LPRM utility, you can delete print jobs by typing the following command:

> LPRM [ -P printer ] [ -H host ] [ -q ] [ job# [ ... ]] [ username [ ... ] ]

The table below describes the LPRM command-line options and parameters.

LPRM Options and Parameters

Options and Parameters | Description -P printer | This option and parameter specify a print queue. This is the ASCII name as it appears in the /etc/printcap file or the equivalent on the remote host. By default, LPRM uses the first PRINTER: entry in the PRINT.CFG file.
-H host | This option and parameter specify the host to which printer is connected. The host can be the hostname or the IP address in dotted notation. By default, LPRM uses the hostname associated with the first PRINTER: entry in the PRINT.CFG file.
-q | This option specifies the quiet mode, suppressing the reporting of command status.
job # [...] | This parameter specifies the job numbers to delete. The job number must be typed in digits. If you do not specify job #, LPRM assumes job # is all jobs owned by username. You can specify a maximum of 20 jobs.
username [...] | This parameter specifies the user's name. The name must begin with an alpha character and the default is all users. You can specify a maximum of five usernames.

For example, to delete job 35 for user Evelyn queued at the LASER1 printer connected to the host VENUS, type the following command:

>     LPRM -P LASER1 -H VENUS 35 evelyn <Enter>

The LPRM utility displays the following message:

>     LPRM - Copyright (c) 1992, Novell, Inc.
>     Removing jobs from the print queue for LASER1 on VENUS
>     db:dfA234VENUS dequeued

#### Deleting Jobs with the RPD Utility

The RPD utility deletes print jobs from a remote printer's queue.

Before you can delete a print job, you must find its job ID using the RPS command. If the remote printer is on a UNIX host, RPS displays the job ID in the Job column; if it is on a VMS host, RPS displays the job ID in the Entry column.

You can delete a job from a remote print queue by typing the following command:

>     RPD [ -P printer ] [ -L username ] job_id

The table below describes the RPD command-line options and parameters.

RPD Options and Parameters

Options and Parameters | Description -P printer | This option and parameter specify a remote print queue. If you omit the -P option, RPD uses the first printer entry listed in your printer configuration file. The first entry is the name of the default printer.
-L username | This option and parameter specify the name of the user who sent the job you are deleting. This is the name of the account through which you are accessing the remote host. If you omit this option, RPD selects the username you or your LANWP.BAT file established with the DOS SET NAME command.
job_id | This parameter specifies the identifier of the job you are deleting. The format of the job identifier depends on the remote host. You must type the job identifier exactly as it is displayed by RPR or RPS.

The response RPD displays when it deletes a print job depends on the remote host. If the remote printer is attached to a UNIX BSD host, RPD displays a message similar to the following one:

>     evelyn_pc: dfA936sales dequeued

If the remote printer is attached to a VMS host, RPD typically does not display a message.

Top Previous: Transferring Files Next: Executing Commands on a Remote Host