Visit Our UNIX and Linux User Community


Catching print jobs.


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Catching print jobs.
# 1  
Old 08-22-2008
Catching print jobs.

Hi,

I am wondering how to catch print jobs to process them before been served to the printer.

I was told that the challenge is to catch raw text that an old legacy application sends to the printer (invoices, quotes, etc) and save them as text files to allow a new application to process them doing diferent new stuff that the old app can not.

We need to try this approach because there are no people that can change the legacy app's code. The client is thinking on change the app but we need to offer a solution now.

Does anybody konws how to do that?

Thanks in advance.
# 2  
Old 08-22-2008
If its your application that sends the print, you could try to disable the printer then go and fetch what is in the queue...
# 3  
Old 08-22-2008
Also, depending on the OS and queuing system used, you could write a simple printer filter as a shell script that would do the work for you. So... What OS and printing system are you on?
# 4  
Old 08-22-2008
I just know it is UNIX (don't know which one),

And I was told it uses the lpr command to print, it is all I know.

Do you have a link to a tutorial o something to do that script?
# 5  
Old 08-23-2008
"UNIX" can mean a lot of things.

Ok, here's what you can do, replace lpr with a script.

First, find out where it lives. Let's say for example it's /usr/bin/lpr.

Then replace with a script that logs how it's called and tries to copy the printer output to a file.

Code:
$ su
Password:
# mv /usr/bin/lpr /usr/bin/real.lpr
cat > /usr/bin/lpr
#!/bin/sh
exec >/tmp/lpr.debug 2>&1
set +xv
echo "Lpr called on `date` with these arguments:"
echo "0:$0 1:$1 2:$2 3:$3 4:$4 5:$5 6:$6 7:$7 8:$8 9:$9"
filenames=""
args=""
while [ $# -gt 0 ]; do
  case $1 in
    -* ) args="$args $1" ;;
    * ) filenames="$filenames $1" ;;
  esac
  shift
done
if [ "$filenames" = "" ]; then
  filenames=/tmp/lpr.stdin
  cat > /tmp/lpr.stdin
fi
cat /dev/null > /tmp/lpr.output
for f in $filenames; do
  cat $f >> /tmp/lpr.output
done
exec /usr/bin/real.lpr $* < /tmp/lpr.output
exit 0
^D
# chmod 755 /usr/bin/lpr

That should get you started. Check /tmp/lpr.debug to see what's happening.
# 6  
Old 08-25-2008
Thanks Danny,

I know that saying UNIX is not enough, but is all I have.
Your answer gives me the idea of how to handle this.

This project is not approved yet, but thanks to you guys I have an idea of the different things that I should take in account.
 

Previous Thread | Next Thread
Test Your Knowledge in Computers #528
Difficulty: Medium
The Extended ASCII character set adds support for 128 additional characters (numbered 128 through 255) by adding 1 more bit (16 total).
True or False?

10 More Discussions You Might Find Interesting

1. AIX

Print jobs stuck in queue

Hi, have an aix system with something I've never seen happening. All printers are not printing. I see jobs Queued and printer status as READY but jobs just keep getting queued and nothing's printing. Seems to be a system wide problem since it's affecting all printers. Help... (2 Replies)
Discussion started by: flash88
2 Replies

2. UNIX for Advanced & Expert Users

[Solved] remove all print jobs from a print queue

Hello, Sometimes i need to clear all the jobs of a print queue and it is really annoying to cancel one by one. Is there a way to cancel all print jobs for a specific print queue with a single command instead of cancelling them one by one? My AIX system is 5.3 Thank you for your attention (2 Replies)
Discussion started by: omonoiatis9
2 Replies

3. Shell Programming and Scripting

print q jobs

Hi, I need to get queue name ,status and numbero jobs waiting in queue.I was using lpstat and i got the queue name ,status and number of jobs waiting but the problem with lpstat is that when printer is out of paper then it shows printer status ready and 0 jobs in queue.is there any way that i can... (4 Replies)
Discussion started by: sagii
4 Replies

4. Shell Programming and Scripting

print queue jobs

Hi, i m having problem to get number of jobs waiting using lpstat.my printer is out of paper and 10jobs are in queue but i run lpstat -pqname it didnt show any thing.any one have idea whats wrong here. thanks sagii (2 Replies)
Discussion started by: sagii
2 Replies

5. Shell Programming and Scripting

print queue jobs

Hi, I have one queue that have status QUEUE and 10 jobs are waiting.Can any one guide me how i can get total number of jobs on this queue.i can see 10 jobs but i need to get count 10 for this queue.Please help me out thanks in advance sagii (2 Replies)
Discussion started by: sagii
2 Replies

6. Linux

holding print jobs in CUPS

Hi all. I have a problem with some printers that when I print a lot of jobs at once the printers gets stuck after 2 prints... (It's a barcode printers - DATAMAX). Whenever I'm printing each job separtly with a delay of a few seconds the printers work fine... So my question is how can I... (0 Replies)
Discussion started by: eliraza6
0 Replies

7. HP-UX

Print Queue jobs stuck

Hello, I have a print queue that the jobs are getting stuck in. I've disabled and enabled the queue, lpshut and lpsched the print spooler, and killed a suspected corrupt job. But new requests still get stuck. I can ping the printer by DNS with no problem. What else can I look for? I'm a little... (3 Replies)
Discussion started by: mizzleman
3 Replies

8. SCO

Print jobs getting stuck on the queue

I have implemented Laser printers using USB printer servers connected to a SCO server. Sometimes print jobs get stuck on the queue and I havent found a way of getting the printer back to work without canceling the jobs and rebooting the system. Why jobs get stuck? How do I get this solved... (9 Replies)
Discussion started by: iNetForce
9 Replies

9. SCO

Random duplicated print jobs

I have a weird problem, about 6 times a day a print job will be printed twice (out of more than 100 print jobs per day). It seems as though sometimes a print job is not cleared from the print spooler after the first print, and then reprints. This started a week ago after I had made printer... (1 Reply)
Discussion started by: Barry Staples
1 Replies

10. UNIX for Dummies Questions & Answers

Deleting a batch of print jobs

Hi Guys I have over 2000+ print jobs in one queue which I would like to delete. Is there away in AIX 4.3 that I can delete the whole print jobs at ocne. Instead of one at a time. Thanks (1 Reply)
Discussion started by: orvelb
1 Replies

Featured Tech Videos