1833514 Members
3035 Online
110061 Solutions
New Discussion

Re: Can I lp to a file?

 
Tim Medford
Valued Contributor

Can I lp to a file?

I'm trying to issue an lp command and have the output go to a file, rather than a printer. We need to dissect the PCL code (it's a long story!).

If I try piping or redirecting the lp output, all I get is the print request-id information, not the actual output from lp.

Is there a way to do this?

Thanks!!!
4 REPLIES 4
Stefan Schulz
Honored Contributor

Re: Can I lp to a file?

Hmm i can think of one quick and dirty trick. Disable the printer and print. You will then find two files in the requests directory. i thing thats in /var/spool/lp/requests, but i don?t have a HP-UX machine at hand right now. One of the files is the control file (ASCII Code) and one is the printerfile you are looking for.

Alternatevely you could set up a new printer and modify its model script. Also somewhere in the /var/lp directory.

Hope this helps a bit.

Regards Stefan
No Mouse found. System halted. Press Mousebutton to continue.
Steffi Jones_1
Esteemed Contributor

Re: Can I lp to a file?

This has to be done by setting up the disk file as a printer to lp(1).

The steps to do this are as follows:

1) create the "device" file as an empty file with:
touch /tmp/printer

2) shut down the scheduler:
/usr/lib/lpshut

3) add the new "printer" to the spooler:
/usr/lib/lpadmin -ddiskfile -mdumb -v/tmp/printer
where "diskfile" is the name of your printer.

4) accept and enable the printer:
/usr/lib/accept diskfile
enable diskfile

5) restart the scheduler :
lpsched

That might work... good luck,

Steffi Jones
Al Langen
Advisor

Re: Can I lp to a file?

I know that this has been answered before. You can do this without disabling the printer if the device you are printing to is /dev/null. Simply, use the dumbplot interface file and change the
cat "$file" ... line to
cat "$file" >> /tmp/your_filename
It's not the ups and downs in life, it's the jerks. A. E. Newman
JACQUET
Frequent Advisor

Re: Can I lp to a file?

Hello,

I can suggest you an other solution, in order to fullfill /var System FS because of the files send by the Unix Spooler in the directory /var/spool/lp/requests/.
You can create an interface script which copy the file send to the spooler (so in /var/spool/lp/requests) to an other directory (FS) and do a special task.
1?) Create a printer with an interface file :
lpadmin -pMYPRINTER -v/dev/null
-i/home/users/shell.sh
The file /home/users/shell.sh in this example could contain lines like this (to catch parameters sent to the spooler)
#!/usr/bin/ksh
i=0
maxi=5
while [ $i -lt $maxi ] do ; shift ; (( i = i + 1)) ; done
files="$*"
for fic in $files
do
# you put your tasks on the files here
done

Here it is
Hope it can help...

P.S : be careful if you want to modify this interface script after printer settings, because the shell is settle in the /etc/lp/interface directory, and got the name of the created printer.
PJA