The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 08:52 PM
Print jobs getting stuck on the queue iNetForce SCO 9 04-20-2007 08:20 PM
Random duplicated print jobs Barry Staples SCO 1 03-20-2007 05:34 PM
jobs stalled in remote print queue antalexi UNIX for Advanced & Expert Users 0 08-03-2004 12:07 PM
Deleting a batch of print jobs orvelb UNIX for Dummies Questions & Answers 1 02-09-2001 12:20 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-22-2008
miguel77mex miguel77mex is offline
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.
  #2 (permalink)  
Old 08-22-2008
vbe's Avatar
vbe vbe is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2005
Location: Switzerland - GE
Posts: 1,568
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 (permalink)  
Old 08-22-2008
Danny.Chouinard Danny.Chouinard is offline
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?
  #4 (permalink)  
Old 08-22-2008
miguel77mex miguel77mex is offline
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?
  #5 (permalink)  
Old 08-23-2008
Danny.Chouinard Danny.Chouinard is offline
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.
  #6 (permalink)  
Old 08-25-2008
miguel77mex miguel77mex is offline
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.
Sponsored Links
Closed Thread

Bookmarks

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 Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:46 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0