Question & Answer
Question
AIX System V Printing - Adding a System V Printer From the Command Line: Lab 1
Answer
PowerPC) printing to the System V print subsystem. If you have not done this, follow the directions in Changing to the System V Print System: Lab0. System V printers can only be added from the command line or from Web-based System Manager. They are not supported from SMIT.
This document only applies to AIX 5L and later when using the System V Print subsystem.
This lab goes through the following steps:
- Differences in nomenclature
- Adding a local printer device
- Adding a local text printer
- Adding a local PostScript printer
- Removing the test printers
- What you have learned
Differences in nomenclature
In the AIX (PowerPC) print subsystem the destination device for a print command is a queue while in System V printing, the destination is called a printer. The following table shows some of the key naming differences between the two print subsystems available on AIX 5L.
AIX name SystemV name Description qdaemon lpsched The print subsystem scheduler queue printer destination for print command qprt -Pqueuelp -d printer Sample print command rembak lpNet Command to send remote print jobs lpd lpNet Daemon to receive remote print jobs piohpnpf hpnpf Command to send to JetDirect printers pioout lp.cat Command to deliver job to local printer device virtual printer backend Interface script Software to format/filter output predef file model file Sample definition file for creating virtual printers (AIX) or printer (SystemV)
Adding a local printer device
There are no changes from the AIX print subsystem for the System V print subsystem when adding printer devices and any devices that you already have added will remain when you switch to the System V print subsystem. If you haven't already added a device follow these instructions:
- Cable the device
- Start SMIT with the devices fastpath and select Printer/Plotter
# smitty devices
- Choose Printer/Plotter followed by Printer/Plotter Device
- Choose Add a Printer/Plotter
- Choose the printer name from the list
- Choose the printer interface of parallel, rs232, or rs422.
- Choose the Parent adapter
- Select the PORT number and adjust any timeout settings then press the Enter key.
- Exit SMIT and check for printer devices.
# lsdev -Cc printer
Adding a local text printer
The lpadmin command is used to add the System V printer. The syntax is
lpadmin -p printer -v device -T printer-type -I content-type [options]
- printer is the name you will use when printing from lp.
- device is the device file for the printer device (/dev/lp0) or a file that you choose to print to for testing.
- printer-type is the TERM type of the printer.
For a HP LaserJet and most other laser printers this is hplaser.
This type name must
correspond to a terminfo TERM type. You can check a term type
by looking in the /usr/lib/terminfo directory under a subdirectory
of the first letter of the TERM name. For example since hplaser
starts with an 'h' look in /usr/lib/terminfo/h. Check the
init string for your terminal with:
# tput -T hplaser init | od -a 0000000 esc E esc & k 0 G cr 0000010
- content-type is the content type of files you will print. The default is simple, which assumes that you have a file that can print with no changes. (It contains carriage returns or raw print data). In this lab we will create two printers with different content types to illustrate the different output.
- options will include things like form and user support and won't be used in this initial lab.
Adding a simple printer to print to file /dev/simple:
The following directions specify how you can print to a file.
This is useful for understanding exactly what is sent to a printer.
Although these instructions specify a file, the -v flag
could just as easily point to the device created in the previous
step. For example to create a printer for lp0, use:
# lpadmin -p text1 -v /dev/lp0 -T hplaserFor the rest of the lab, we will use files instead of printers so that we can examine the output more carefully. If you print to the printer defined above, you are likely to find that it does not have the proper carriage control characters added. After you follow this lab, you will understand what you can add to solve this problem.
Here are the directions for adding a printer that prints to a file instead of a device:
# touch /dev/simple # chmod 600 /dev/simple # chown lp /dev/simple # lpadmin -p text1 -v /dev/simple -T hplaser # accept text1 UX:accept: INFO: destination "text1" now accepting requests # enable text1 UX:enable: INFO: printer "text1" now enabledNow check to see what was created for the printer text1
# ls -l /etc/lp/printers total 8 drwxrwxr-x 2 lp lp 512 Apr 23 16:53 text1 # ls -l /etc/lp/printers/text1 total 40 -rwxrwx--- 1 lp lp 2384 Apr 23 16:53 alert.sh -rw-rw---- 1 lp lp 4 Apr 23 16:53 alert.vars -rw-rw-r-- 1 lp lp 151 Apr 23 16:53 configuration -rw-rw-r-- 1 lp lp 8 Apr 23 16:53 forms.deny -rw-rw-r-- 1 lp lp 4 Apr 23 16:53 users.allow # cat /etc/lp/printers/text1/configuration Banner: on:Always Content types: simple Device: /dev/simple Interface: /usr/lib/lp/model/standard Printer type: hplaser Modules: default Form feed: on # ls -l /etc/lp/ # ls -l /etc/lp/interfaces total 56 -rwxrwxr-x 1 lp lp 25764 Apr 23 16:53 text1Now it's time to print a simple job to this file:
# lptest 5 5 | lp -d text1 request id is text1-1 (standard input)Now see that the requests file is updated. (It is added the first time you print.
# ls -l /var/lp/logs total 24 -rw-r--r-- 1 lp lp 195 Apr 23 16:23 lpNet -rw-r--r-- 1 lp lp 68 Apr 23 16:23 lpsched -rw-rw---- 1 lp lp 171 Apr 23 17:00 requestsDid the job print to /dev/simple?
# ls -l /dev/simple -rw-rw-rw- 1 root system 228 Apr 23 17:00 /dev/simple # cat /dev/simple ##### ##### ##### ##### ##### ##### User: aix4prt!root ##### ##### Printed: Mon 17:00 Apr 23, 2002 ##### ##### Job number: text1-1 ##### ##### ##### ##### ##### !"#$% "#$%& #$%&' $%&'( %&'()This shows that the banner was added by the interface program. To see what else was added use the od command as shown here:
# od -a /dev/simple 0000000 esc E esc & k 0 G cr cr # # # # # cr lf 0000020 # # # # # cr lf # # # # # cr lf # # 0000040 # # # cr lf # # # # # cr lf # # # # 0000060 # sp sp sp sp sp sp sp U s e r : sp a i 0000100 x 4 p r t ! r o o t cr lf # # # # 0000120 # cr lf # # # # # sp sp sp sp P r i n 0000140 t e d : sp M o n sp 1 7 : 0 0 sp A 0000160 p r sp 2 3 , sp 2 0 0 1 cr lf # # # 0000200 # # cr lf # # # # # sp J o b sp n u 0000220 m b e r : sp t e x t 1 - 1 cr lf # 0000240 # # # # cr lf # # # # # cr lf # # # 0000260 # # cr lf # # # # # cr lf # # # # # 0000300 cr lf cr ff ! " # $ % lf " # $ % & lf 0000320 # $ % & ' lf $ % & ' ( lf % & ' ( 0000340 ) lf cr ff 0000344Notice the following:
- esc E is a printer reset.
- esc & k 0 G tells the printer not to add carriage returns.
- The header page lines end in cr lf.
- The text output from lptest does not have cr added to
line feeds.
0000320 # $ % & ' lf $ % & ' ( lf % & ' (
- The interface adds a carriage return and form feed at the end.
Adding a text printer to print to file /dev/text:
By changing the content type, we can cause the scheduler to
use filters in such a way as to add the carriage returns. What may
seem strange is that to do this, use the content type of pcl.
Note: In this case I set the /dev/text file to be owned by
user lp with permissions of 600 and avoid the lpadmin
error message seen in the earlier example.
# touch /dev/text # chown lp /dev/text # chmod 600 /dev/text # lpadmin -p text2 -v /dev/text -T hplaser -I pcl # accept text2 UX:accept: INFO: destination "text2" now accepting requests # enable text2 UX:enable: INFO: printer "text2" now enabled # lpstat -a text1 accepting requests since Mon Apr 23 16:54:41 2002 text2 accepting requests since Mon Apr 23 18:12:45 2002Print to the text2 queue as before
# lptest 5 5 | lp -d text2Comare the output to the earlier output:
# diff /dev/simple /dev/text ... !"#$% > "#$%& > #$%&' > $%&'( > %&'() --- > !"#$% > "#$%& > #$%&' > $%&'( > %&'()This looks the same, but use od to examine the new file
# od -a /dev/text ... 0000320 cr lf # $ % & ' cr lf $ % & ' ( cr lf 0000340 % & ' ( ) cr lf cr ffNotice how there are now cr lf pairs in the date where there were only lf in the first example. This is because the pcl filter was used to convert the file from type simple which is the default for the lp command, to type pcl which is the type for this printer. To see the differences between the two printer configurations use the lpstat command.
# lpstat -p text1 -l printer text1 is idle. enabled since Mon Apr 23 16:54:58 2002. available. Form mounted: Content types: simple Printer types: hplaser Description: Connection: direct Interface: /usr/lib/lp/model/standard On fault: mail to root once After fault: continue Users allowed: all Forms denied: all!all Banner required Character sets: (none) Default pitch: 10 CPI 6 LPI Default page size: 80 wide 60 long Default port settings: # lpstat -p text2 -l printer text2 is idle. enabled since Mon Apr 23 18:13:00 2002. available. Form mounted: Content types: pcl Printer types: hplaser Description: Connection: direct Interface: /usr/lib/lp/model/standard On fault: mail to root once After fault: continue Users allowed: all Forms denied: all!all Banner required Character sets: (none) Default pitch: 10 CPI 6 LPI Default page size: 80 wide 60 long Default port settings:
Now that you have solved the problem printing to a file try this to the printer device by adding this printer
# lpadmin -p text2lp0 -v /dev/lp0 -T hplaser -I pcl
Adding a PostScript printer to print to file /dev/ps1:
If you are printing to file with a PS filter, it is important that the content type be set to printer type to PS-b, because this uses lp.cat to send the data to the printer while PS uses the postio filter which will hang when printing to a file, but which will print fine if you are attached to a real printer. Here are the commands to setup to print to a file as a PostScript printer.
# touch /dev/ps1 # chown lp:lp /dev/ps1 # chmod 600 /dev/ps1 # lpadmin -m PS -T PS-b -I PS -p fileps -v /dev/ps1 - This uses model PS, set the printer type to PS-b, set the content type to PS and use device /dev/ps1. # accept fileps # enable fileps # lpstat -p fileps -l printer fileps disabled since Tue Apr 24 08:23:54 2002. available. new printer Form mounted: Content types: PS Printer types: PS-b Description: Connection: direct Interface: /usr/lib/lp/model/PS On fault: mail to root once After fault: continue Users allowed: all Forms denied: all!all Banner required Character sets: (none) Default pitch: Default page size: 80 wide 66 long Default port settings:
Printing to the PostScript printer:
Use the lp command to print to printer fileps. At first we will try with no content flags:
# lptest 5 5 | lp -d filepsIf you did not run the accept command, you would get this error.
UX:lp: ERROR: 0920-067 Requests for destination "fileps" aren't being accepted. TO FIX: Use the "lpstat -a" command to see why this destination is not accepting requests.
Printing a text file to a PostScript printer
Assuming that you did run the accept and enable commands, the print command will look like this:# lptest 5 5 | lp -d fileps request id is fileps-4 (standard input)Now look at the file /dev/ps1 with pg or more.
pg /dev/ps1Notice that the file starts with %!PS which is the standard start for a PostScript document. Then a PostScript method called banner is defined:
%!PS % @(#)71 1.1 src/bos/usr/bin/svprint/cmd/lp/filter/postscript/postscript /banner.ps, svprint, bos510 5/30/00 11:25:12 %ident "@(#)banner.ps 1.1" % % Simple program to print a banner page % % 04/19/91: % Modified to be more compatable with how other LP % banner pages look. % /banner { /saveobj save def erasepage initgraphics ... (Owner:) nextline (Originator:) nextline (Title:) nextline (Job-Id:) nextline (Printed:) nextline showpage saveobj restore } bind defNext the parameters for the banner page are put on the stack, and the banner method is called.
(Tue 08:39 Apr 24, 2002) (fileps-4) (<untitled>) (aix4prt!root) (aix4prt!root) bannerNext the PostScript output from converting the text file to PostScript will be shown. This is because the default content type for the lp command is simple, but the printer has been defined with content type PS, so the postprint filter has been called.
%!PS-Adobe-2.0 %%Version: 3.15 %%DocumentFonts: (atend) %%Pages: (atend) %%EndComments ... % Version 3.15 prologue for ASCII files. % ... The text is wrapped in parenthesis and the l method called to print the text as a line. (!"#$%)l ("#$%&)l (#$%&')l ($%&'\()l (%&'\(\))l cleartomark restore showpage
Print a PostScript file to a PostScript printer
A sample PostScript file is included in the distribution as /usr/lib/hpnp/testfiles/ps. Clear the printer destination file, and try printing this file:> /dev/ps1 # This clears the file # lp -d fileps /usr/lib/hpnp/testfiles/ps request id is fileps-5 (1 file)Examine the /dev/ps1 file with pg or more and you will see that the PostScript file has also been run through the postprint filter and if you print this to a real printer will print the PostScript source and not the desired output.
Now print the file with the -T PS flag.
> /dev/ps1 # This clears the file # lp -d fileps -T PS /usr/lib/hpnp/testfiles/psThis time when you pg through /dev/ps1, you should notice that the PostScript file has not been converted again to PostScript. This is most visible in the difference between lines like
Without -T PS the line is wrapped in parenthesis and l is added (192.983 565.483 180 581.5 162.5 577.5 c)l With -T PS no conversion of the line is done 192.983 565.483 180 581.5 162.5 577.5 c
If this file is printed to a real PostScript printer, it will print as desired when using the -T PS flag.
Removing the test printers
To remove the printers you created, use the lpadmin command with the -x flag followed by the printer name# lpadmin -x fileps # lpadmin -x text1 # lpadmin -x text2 # lpstat -p *This will show remaining printers
What you have learned
In this lab, you learned how to:- Use the lpadmin command to create text and
PostScript printers to files.
-
To print to a real printer change the lpadmin -v command to
print to the printer device file in /dev.
- Use the lp command to print to the printer.
- Use the lpstat -p command to list your printers.
- Use the lpadmin -x flag to remove printers.
- Examine the contents of the file.
- Set the content type of the input file with the lp -T
flag to change the filters that are automatically called.
- Using -T pcl to add carriage returns to line feeds.
- Using -T PS to keep PostScript files from printing as source.
Next try to duplicate the PostScript printer steps with a real printer.
Was this topic helpful?
Document Information
Modified date:
17 June 2018
UID
isg3T1000455