Operating System - HP-UX
1754341 Members
4875 Online
108813 Solutions
New Discussion юеВ

Using a PCL file with the "lp" command in UNIX

 
SOLVED
Go to solution
Lynne Paris
New Member

Using a PCL file with the "lp" command in UNIX

I'm new to PCL, so please forgive my ignorance....

We are currently using a HP LaserJet 8000 printer and printing from UNIX. In the past (sorry, not sure what type of printer we used before), we had created separate PCL files (with a .pcl extension) and fed those to the lp command to get the output formatted the way we wanted. For example:

lp -d sample.pcl

where sample.pcl contains the relevant PCL codes to get the output correctly formatted. Now it treats these as as two files, trying to print the .pcl file rather than using it to give format commands to the printer.

Is there a different command we should be using? Or are their settings we need to configure on the printer?

Thanks for any help!!
9 REPLIES 9
Sanjay_6
Honored Contributor
Solution

Re: Using a PCL file with the "lp" command in UNIX

Hi Lynne,

How is the printer connected to the system. Is it through the network or on the local parallel port. If it is on the local parallel port, you can cat the file on the parallel port and see is it works,

cat sample.pcl file_name > /dev/lp0

Make sure lp0 is the device file for the parallel port on which the printer is connected locally.

I can't say how you could be printing the two files together in one single command without the printer trying to print it as two seperate files. The only option could have been without a formfeed between the two prints. In such a case the first file contain some printer setting commands and the 2nd file is the actual printout. You can try it by turning the page feed after printout off.

Hope this helps.

Regds
Steve Steel
Honored Contributor

Re: Using a PCL file with the "lp" command in UNIX

Hi

Assuming you are using Jetdirect there is a man page.


net_ljx000(1) net_ljx000(1)




NAME
net_ljx000 - HP JetAdmin model script

SYNOPSIS
lp [ -o option [ -o option ] ...]

DESCRIPTION
The model script net_ljx000 is one of the net_lj* model scripts included in HP JetAdmin distribution. While most options are common among the net_lj* model scripts, net_ljx000 contains expanded options specifically for the HP LaserJet 4000, HP LaserJet 5000, HP LaserJet 8000, HP LaserJet 8100 and HP Mopier 320. For example, more values
for the dpi option, more media size options, and a fuser temperature option.

The model script net_ljx000 will not print the following files: shar file, executable, archive, library, object, and compressed. Instead, it prints out a single page, indicating the reason.

OPTIONS
options List all available options for net_ljx000.

auto Auto-switch language (PostScript or PCL) based on file
type. Default.

postscript/post, pcl
Print in PostScript or PCL mode.

hpgl2, hpgl2_p Print in HP-GL/2 landscape or portrait mode.

relay Pass data to the printer without adding any commands.

r/raw Print in raw mode. No CR, LF, or FF processing will be
performed.

dpi<#> Set the resolution to the specified dpi, where <#> is
either 3/300, 6/600, 12/1200/12pro, or 12fast/1200fast.
If <#> is not specified, the printer's front panel sets
the default dpi. The 12pro sets true 1200 dpi with
slow speed at 8ppm. All other dpi settings print
faster at 16ppm speed for LaserJet 4000 and LaserJet
5000, 24ppm speed for LaserJet 8000, 32ppm speed for
LaserJet 8100 and Mopier 320. The 12/1200/12pro is not



Ensure that you are using the correct script.

Give the -opcl

Then try

1)As 2 seperate files

2)Cat files|lp -dprinter -opcl


The second should work


Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
Trond Haugen
Honored Contributor

Re: Using a PCL file with the "lp" command in UNIX

Seems the printer is reset when starting to print each file. This could probably be commented out in the interface script but it's not recommended.
Depending on what your sample.pcl file does it could be you could achieve the same with lp-options. If not something along Sanjay suggestion may be the answer. If you don't have a hard-wired printer you may try: cat sample.pcl file_name > newfile, lp -dprinter newfile.

Regards,
Trond
Regards,
Trond Haugen
LinkedIn
K.Vijayaragavan.
Respected Contributor

Re: Using a PCL file with the "lp" command in UNIX

If it is a network printer you can use the command,
"#hpnpf -x filename
see man page of hpnpf for more options.

-Vijay
"Let us fine tune our knowledge together"
Steve Steel
Honored Contributor

Re: Using a PCL file with the "lp" command in UNIX

Hi

use lpr instead of lp

lpr -dprinter -opcl (parameters) pclfile file

It is /usr/bin/lpr and a simple script if you wish to play with it.


Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
Lynne Paris
New Member

Re: Using a PCL file with the "lp" command in UNIX

Thanks to everyone that replied. Between all of you I was able to get on the right path and understand better how to actually implement PCL.

The solution that actually worked best for my situation was:

cat | lp -d


(By the way, my printer was networked, not local).
This got it to the point where it was starting to show it could change orientation and such, but the indentation was still coming out wrong. Turned out I had to remove the reset command (EcE) that was at the beginning of the PCL file for it to print properly.

Commands I tried that did not work:
lp -d -opcl
lpr -d -opcl

A great reference document I used that aided my understanding of each PCL command that came from this web site was "HP LaserJet Printers - PCL Commands, Basic Page Formatting, and Font Selection". I just wish that document would have made some attempt at explaining how to actually implement the PCL commands, expecially in the UNIX environment. Would have saved us all a lot of time
Bill Hassell
Honored Contributor

Re: Using a PCL file with the "lp" command in UNIX

Important notes:

- The printer must be reset after EVERY job. Otherwise, subsequent jobs will inherit settings, fonts, macros, etc from previous jobs. A job is defined as a file that is given to lp to print. lp file1 file2 is actually 2 separate jobs.

- lpr does not exist as HP-UX is SysV not BSD and the lpr command is from the BSD flavors of Unix. lpr on HP-UX is a simple lp-wrapper script.

Note that pure PCL files that were created on another platform (ie, a PC) will not print correctly due to CR/LF issues. Unix never provides CR after the LF in an ASCII file so the printer script always provides this. However, a PC driver adds the appropriate CR to LF characters and if printed without -oraw option, the PCL file will have extra CR's added throughout the file whether needed or not.

In your case, the PCL file is actually a simple preface to the ASCII file and will work fine in the mode you have chosen. Just be aware of the issues with CR/LF when dealing with HP-UX.


Bill Hassell, sysadmin
Lynne Paris
New Member

Re: Using a PCL file with the "lp" command in UNIX

Bill,

The reset "EcE" was the first command in what I'm calling my "PCL File". Then it would have commands following in the same line to do other manipulations like change font size, print landscape, etc.

I already know I can't have EcE as the first command, because then it WOULD interpret landscape and some of the commands correctly, but it WOULD NOT do the indentation correct.

I don't think I can put the reset command as the last command of my PCL file, because I would think it would reset all the commands I just set before it printed the file I wanted to affect. So, any other suggestions how to reset after every file as you made mention was needed in my case?

My "PCL file" gets reused generically by many reports. So it's not as simple as being able to add the reset command to the end of the file I'm trying to print. Unless maybe I create a "reset PCL" file and cat that as the third file in the string? Like:
cat | lp -d

At any rate, it seems like the printer is resetting itself on it's own, as subsequent print outs do not seem to be affected by my PCL file changes. In theory, is that possible? It is in reality.

I understand how the original command (lp -d ) is interpretted as two files to print. This is just a piece of code I inherited. What I don't understand is how it ever worked right in the first place. Maybe it never did?!? I don't know for sure. Haven't been a part of this project long enough.

Anyway, I appreciate the insight and any other tips you have to offer.

Bill Hassell
Honored Contributor

Re: Using a PCL file with the "lp" command in UNIX

Sorry, the EscE printer reset I was referring to is found at the beginning of all standard LaserJet models scripts. This may be why the code may have worked in the past: not using the correct model script for the printer. So regardless of what you are printing, the printer script adds EscE prior to the job.

Also make sure that someone has not changed the default fonts and spacing, etc on the printer. All of these can be overridden in your PCL control file but you must enumerate *every* setting...or you can cold reset the printer (turn it off, hold the online key down and then turn it on again while holding the online key down. The front panel will show COLD RESET when done successfully. NOTE: if you manually set the network interface from the front panel, you'll have to reenter the settings again.

As far as the indents go, there are a dozen different ways to perform indenting using PCL codes but many depend on current printer settings. If the indents aren't stable, use a different technique that is not affected by previous settings.

To see exactly what was sent to the printer on a particular job, use the disable commnand to turn off the printer output. Then print the job and cd to the print spool directory (/var/spool/lp/request/ and you'll see 2 files, a control file (with lp options) and a data file. The data file is exactly what the printer will see. Use cat -v to see the actual escape sequences.


Bill Hassell, sysadmin