The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Print Queue jobs stuck mizzleman HP-UX 3 07-02-2008 05:52 PM
Print jobs getting stuck on the queue iNetForce SCO 9 04-20-2007 05:20 PM
Random duplicated print jobs Barry Staples SCO 1 03-20-2007 02:34 PM
jobs stalled in remote print queue antalexi UNIX for Advanced & Expert Users 0 08-03-2004 09:07 AM
Deleting a batch of print jobs orvelb UNIX for Dummies Questions & Answers 1 02-09-2001 09:20 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 08-22-2008
Registered User
 

Join Date: Aug 2008
Posts: 3
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.
Reply With Quote
Forum Sponsor
  #2  
Old 08-22-2008
vbe vbe is offline
Moderator
 

Join Date: Sep 2005
Location: Switzerland
Posts: 775
If its your application that sends the print, you could try to disable the printer then go and fetch what is in the queue...
Reply With Quote
  #3  
Old 08-22-2008
Registered User
 

Join Date: May 2008
Posts: 21
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?
Reply With Quote
  #4  
Old 08-22-2008
Registered User
 

Join Date: Aug 2008
Posts: 3
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?
Reply With Quote
  #5  
Old 08-23-2008
Registered User
 

Join Date: May 2008
Posts: 21
"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.
Reply With Quote
  #6  
Old 08-25-2008
Registered User
 

Join Date: Aug 2008
Posts: 3
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.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
catch print job, lpr filter, print jobs, print spool, printing, unix catch printing jobs, unix print

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:02 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0