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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
12-02-2008, 05:56 PM
|
#1
|
Member
Registered: Apr 2008
Location: Cleveland, Ohio
Distribution: SuSE, CentOS, Fedora, Ubuntu
Posts: 106
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, 08: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, 01:31 PM
|
#3
|
Member
Registered: Apr 2008
Location: Cleveland, Ohio
Distribution: SuSE, CentOS, Fedora, Ubuntu
Posts: 106
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, 01: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, 04:56 PM
|
#5
|
Member
Registered: Apr 2008
Location: Cleveland, Ohio
Distribution: SuSE, CentOS, Fedora, Ubuntu
Posts: 106
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, 05: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, 07:23 PM
|
#7
|
Member
Registered: Apr 2008
Location: Cleveland, Ohio
Distribution: SuSE, CentOS, Fedora, Ubuntu
Posts: 106
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, 07: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, 08:05 PM
|
#9
|
Member
Registered: Apr 2008
Location: Cleveland, Ohio
Distribution: SuSE, CentOS, Fedora, Ubuntu
Posts: 106
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, 08: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, 04:45 PM
|
#11
|
Member
Registered: Apr 2008
Location: Cleveland, Ohio
Distribution: SuSE, CentOS, Fedora, Ubuntu
Posts: 106
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.
|
|
|
All times are GMT -5. The time now is 07:58 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
|
|