Operating System - HP-UX
1828390 Members
3506 Online
109977 Solutions
New Discussion

Configure printer to print to a file

 
SOLVED
Go to solution
Whit Murrill
Occasional Contributor

Configure printer to print to a file

We have a legacy hpux application that creates reports that must be viewed on screen or printed to a printer. There is no option to save to a file. I am pretty sure the reports are in PCL, since we have to use laserjets. How can I set up a printer to print to a file instead of a device?
2 REPLIES 2
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Configure printer to print to a file

The most straightforward way to do this is to create a named pipe for the lp device when you add the printer in the conventional way.


e.g. mknod p /dev/mylppipe

Now when you add the printer using SAM or lpadmin use /dev/mylppipe for the device.

That's half of the battle but now we need a daemon to actually read from the named pipe and send it to a file.

e.g.
typeset -i10 NN=0

while true
do
(( NN += 1 ))
OUTFILE="/mydir/fname${NN}"
cat /dev/mylppipe > ${OUTFILE}
done

This daemon a or a similar loop should be in an rc script to start automatically.

You might add some coding to make the filenames more meaningful -- such as a date/time stamp.

If it ain't broke, I can fix that.
Chris Wilshaw
Honored Contributor

Re: Configure printer to print to a file

As a device is "simply" a file itself, when you set up the printer, you can use something like

lpadmin -pPRINTER -vFILE -mdumb

This will send the output to whatever the filename is that you specify.