Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
12-02-2008, 04:56 PM
|
#1
|
|
Member
Registered: Apr 2008
Location: Cleveland, Ohio
Distribution: SuSE, CentOS, Fedora, Ubuntu
Posts: 104
Rep:
|
How to read the lp job title from a Perl backend script?
I'm using the instructions from here to set up a TEXT-to-file printer.
I'm using CUPS.
How do I get the job title parameter from the lp command, so I can incorporate it in the output file?
Thanks!
|
|
|
|
12-02-2008, 07:58 PM
|
#2
|
|
Member
Registered: Dec 2004
Location: MA
Distribution: Various
Posts: 149
Rep:
|
Quote:
Originally Posted by slinx
I'm using the instructions from here to set up a TEXT-to-file printer.
I'm using CUPS.
How do I get the job title parameter from the lp command, so I can incorporate it in the output file?
Thanks!
|
Job title is the third parameter ($3) (usually not set though)
Hope you read the comments as the article itself is the HARD way as the title says.
--
Tony Lawrence
http://aplawrence.com
|
|
|
|
12-03-2008, 12:31 PM
|
#3
|
|
Member
Registered: Apr 2008
Location: Cleveland, Ohio
Distribution: SuSE, CentOS, Fedora, Ubuntu
Posts: 104
Original Poster
Rep:
|
Thanks Tony, I did check the comments - the perl script seems to work nicely though.
We need a way to put the job title in the output file - is there a way to do it with the parallel port trick?
|
|
|
|
12-03-2008, 12:46 PM
|
#4
|
|
Member
Registered: Dec 2004
Location: MA
Distribution: Various
Posts: 149
Rep:
|
Quote:
Originally Posted by slinx
Thanks Tony, I did check the comments - the perl script seems to work nicely though.
We need a way to put the job title in the output file - is there a way to do it with the parallel port trick?
|
No, you'd need to do it in a "backend" or a Sys V script. You'd just pick up $3 and do whatever you want with it.
Examples of backend scripts are all over the web - google "cups backend".
Sys V scripts: http://aplawrence.com/Unixart/cups_sysv_interface.html
|
|
|
|
12-03-2008, 03:56 PM
|
#5
|
|
Member
Registered: Apr 2008
Location: Cleveland, Ohio
Distribution: SuSE, CentOS, Fedora, Ubuntu
Posts: 104
Original Poster
Rep:
|
Thanks, I tried that, but I can't get it to write anything.
Here's my script:
Code:
#!/bin/bash
job_title=$3
shift;shift;shift;shift;shift
print_dir=/var/www/html/remoteprint
print_date=$(date +%Y-%m-%d_%R)
print_file=$print_dir/$print_date.$job_title
cat $* > $print_file
Well I know it's not right... but what do I need to do, to get it to pass stdin into the output file, named with the job title? It doesn't do anything right now.
|
|
|
|
12-03-2008, 04:24 PM
|
#6
|
|
Member
Registered: Dec 2004
Location: MA
Distribution: Various
Posts: 149
Rep:
|
Quote:
Originally Posted by slinx
Thanks, I tried that, but I can't get it to write anything.
Here's my script:
Code:
#!/bin/bash
job_title=$3
shift;shift;shift;shift;shift
print_dir=/var/www/html/remoteprint
print_date=$(date +%Y-%m-%d_%R)
print_file=$print_dir/$print_date.$job_title
cat $* > $print_file
Well I know it's not right... but what do I need to do, to get it to pass stdin into the output file, named with the job title? It doesn't do anything right now.
|
Are you sending the title (-t) ?
|
|
|
|
12-03-2008, 06:23 PM
|
#7
|
|
Member
Registered: Apr 2008
Location: Cleveland, Ohio
Distribution: SuSE, CentOS, Fedora, Ubuntu
Posts: 104
Original Poster
Rep:
|
Yes, I am. My lp command looks like
Code:
lp -d TEXT -t CUPSD /etc/cups/cupsd.conf
(just using cupsd.conf as a sample file to print)
Now, I set up my printer to send the output to /dev/null, because the interface should handle sending the data to the file, right? Or do I need to do something different? Here is my printer definition:
Code:
<Printer TEXT>
Info TEXT
DeviceURI parallel:/dev/null
State Idle
Accepting Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
</Printer>
|
|
|
|
12-03-2008, 06:47 PM
|
#8
|
|
Member
Registered: Dec 2004
Location: MA
Distribution: Various
Posts: 149
Rep:
|
Quote:
Originally Posted by slinx
Yes, I am. My lp command looks like
Code:
lp -d TEXT -t CUPSD /etc/cups/cupsd.conf
(just using cupsd.conf as a sample file to print)
Now, I set up my printer to send the output to /dev/null, because the interface should handle sending the data to the file, right? Or do I need to do something different? Here is my printer definition:
Code:
<Printer TEXT>
Info TEXT
DeviceURI parallel:/dev/null
State Idle
Accepting Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
</Printer>
|
No, the interface doesn't need to handle the destination. It just needs to add the title.
|
|
|
|
12-03-2008, 07:05 PM
|
#9
|
|
Member
Registered: Apr 2008
Location: Cleveland, Ohio
Distribution: SuSE, CentOS, Fedora, Ubuntu
Posts: 104
Original Poster
Rep:
|
What do I need to have in the interface to pass the title? Where do I define my output title?
I originally had set up a text printer to print to a file, in this case /usr/archives/txtrpts/report.prn
But we discovered that when multiple users tried to print to the same file, their lpr processes would hang. So I'm trying to write something that won't hang because multiple users are trying to write to the same file simultaneously.
I might just go back to the Perl server listening on a socket, at least I could get that to produce some output...
Thanks for your help.
|
|
|
|
12-03-2008, 07:13 PM
|
#10
|
|
Member
Registered: Dec 2004
Location: MA
Distribution: Various
Posts: 149
Rep:
|
Quote:
Originally Posted by slinx
What do I need to have in the interface to pass the title? Where do I define my output title?
I originally had set up a text printer to print to a file, in this case /usr/archives/txtrpts/report.prn
But we discovered that when multiple users tried to print to the same file, their lpr processes would hang. So I'm trying to write something that won't hang because multiple users are trying to write to the same file simultaneously.
I might just go back to the Perl server listening on a socket, at least I could get that to produce some output...
Thanks for your help.
|
Definitely the direct to file is not suitable for multi-user.
There were other pointers in the comments that might help.
Sure was a lot easier with Sys V interface scripts..
|
|
|
|
12-04-2008, 03:45 PM
|
#11
|
|
Member
Registered: Apr 2008
Location: Cleveland, Ohio
Distribution: SuSE, CentOS, Fedora, Ubuntu
Posts: 104
Original Poster
Rep:
|
Hey Tony, thanks for your help. I ended up modifying a pdf backend script to print to a text file, and it works.
|
|
|
|
| Thread Tools |
Search 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
HTML code is Off
|
|
|
All times are GMT -5. The time now is 02:00 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|