Operating System - HP-UX
1753945 Members
8456 Online
108811 Solutions
New Discussion юеВ

Re: How to duplicate a printer flow to a file ?

 
SOLVED
Go to solution
Olivier Decorse
Respected Contributor

How to duplicate a printer flow to a file ?

Hello,

I have a remote printer that, sometimes, print strange data.
I don't know if the problem comes from the printer, the remote system (Windows nt4 workstation), wire or the hpux system (the application or unix).

I change everything, except the hp9000 system.

To diagnose, i want to duplicate the printer flow, to a file, and verify that the file also contains this strange caracters. How can i do that ?

Thank's in advance.
Olivier.
They say "install windows 2k, xp or better", so i install unix !
7 REPLIES 7
Victor BERRIDGE
Honored Contributor

Re: How to duplicate a printer flow to a file ?

Hi Olivier,

Ive been thinking and can only see (for now) one solution:
- You disable the printer before the print.
- send the request.
- You go to /var/spool/lp/request/lp-name
- you make quick a copy of the files in your working directory
- enable the printer so it prints the request

Now you have the copies you can look at - I dont know if you can put that in a script to execute pehaps as an alias...

In my test I got 2 files:
printer "lpvbe" now disabled
momo:sm/doc # cat reactivate_acct |lp -onb -dlpvbe
request id is lpvbe-3761 (standard input)
momo:sm/doc # cd /var/spool/lp/request/lpvbe
momo:request/lpvbe # ll
total 4
-r--r----- 1 lp lp 94 Nov 30 11:54 cA3761momo
-r--r----- 1 lp lp 113 Nov 30 11:54 dA3761momo
momo:request/lpvbe # file *
cA3761momo: ascii text
dA3761momo: awk program text
momo:request/lpvbe # more cA3761momo
Hmomo
Proot
Jlpvbe-3761
C
Lroot
B
K1
Onb
T
FdA3761momo
fdA3761momo
UdA3761momo
N
A0
momo:request/lpvbe # more dA3761momo
In this I have the original document to be printed...

Hope it helps...
All the best
Victor
Cheryl Griffin
Honored Contributor

Re: How to duplicate a printer flow to a file ?

Here's how to create a print queue that prints to a file.
# touch /tmp/printfile
# chmod 644 /tmp/printfile
# chown lp:lp /tmp/printfile
# lpshut
# lpadmin -pprinter_name_here -mdumb -v/tmp/printfile
# /usr/lib/lpsched
# /usr/lib/accept printer_name_here
# /usr/bin/enable printer_name_here
Test it.
# /usr/bin/lp -dprinter_name_here /etc/copyright

If you routinely clean out /tmp, you may want to create /dev/printfile instead of /tmp/printfile. (that could be dangerous though) Call these whatever you'd like.
"Downtime is a Crime."
Olivier Decorse
Respected Contributor

Re: How to duplicate a printer flow to a file ?

Thank you, but :
Victor : i don't know when the problem will occur, so i have to duplicate file to print everytime, not just one time, when i want ..
Cheryl : i want also to print twice my documents : to the file, AND to the printer !
Not just to a file.

Any other idea ?

Thank's in advance,
Olivier.
They say "install windows 2k, xp or better", so i install unix !
Bill Hassell
Honored Contributor

Re: How to duplicate a printer flow to a file ?

There is no easy way to accomplish this. You can always use the tee command to copy the data being sent to lp as in:

cat some_file_to_print | tee /var/tmp/prnfile | lp -d...etc...

Now the tee command simply stores the some_file_to_print into prnfile, but I suspect that some of your printing is from an application and you can't control how it prints.

So the other way to monitor the tasks is to enable the lp logging (stop lp with lpshut, then restart it with lpsched -v) and when the problem printing occurs, make a note of the time and then look in the /var/adm/lp/log file for a matching job.

Another suggestion is to post some samples of the strange data. Is it a series of ASCII strings, perhaps starting with the word PS or Postscript? If so, then some application is generating Postscript and the printer does not have a Postscript interpreter installed. Or someone is just printing anything on the HP side (including binary and executable files) which generates random characters and lots of almost blank pages.


Bill Hassell, sysadmin
Olivier Decorse
Respected Contributor

Re: How to duplicate a printer flow to a file ?

Hi Bill : thank's for your response, but :

1) you're rigth when saying "i suspect that some of your printing is from an application and you can't control how it prints", so tee is not usable here,

2) lp is already in log mode. The log file just contains the date and hour of the request, and this is not an important information (not always the same !).

3) Data that are printed are only text data :
Before : 02/12/04-08:55:04 - Equipement X is doing task Y
After : 8?/98/:88<(8>:989?(((0:9:8(((├Г IM(M=::(XZI[M(MN(KMOX\M

Any other idea ?

Olivie
They say "install windows 2k, xp or better", so i install unix !
Bill Hassell
Honored Contributor
Solution

Re: How to duplicate a printer flow to a file ?

The bad data looks like binary data such as that from an executable program or library file. Does the report write anything except ASCII text (ie, graphics, pictures, logo, any font changes at all)? If so, this looks like a sync error where an escape sequence to load a font was corrupted and you're seeing the raw font bit patterns.

The only way to copy the the data file is to add cat within the model script for the printer. Remote printers all use the same rlp script. Look at the end of the script and you'll see a line line this:

/usr/sbin/rlp -I$requestid $BSDC ...

Just insert

cat $1 > /somefile

to copy the printfile. Now this will just overlay /somefile for each print job which may not be what you want. Change the /somefile to something like:

cat $1 > /var/tmp/${requestid}.$$

Each print file will have the spooler request id plus the PID of the script when it runs. NOTE: /var/tmp should be very large (several hundred megs) or better yet, specify a special mountpoint for the files.


Bill Hassell, sysadmin
Olivier Decorse
Respected Contributor

Re: How to duplicate a printer flow to a file ?

Thank you, Bill : it works fine !!
Just to wait now, for a bad printer job, and analyse the data ...

Thank's !

Olivier.
They say "install windows 2k, xp or better", so i install unix !