debianmacno-cups
Last change
on this file since 7cdd65d was
7cdd65d,
checked in by Kyle Brogle <broglek@…>, 14 years ago
|
Implemented default queue in client scripts.
Queue argument now optional for gb{r,rm,q}, and also takes form of -q QUEUE
now.
gutenbach-client-config -sset-default QUEUE will set default queue
Updated manpages accordingly.
|
-
Property mode set to
100755
|
File size:
1.2 KB
|
Rev | Line | |
---|
[78eb866c] | 1 | #!/usr/bin/perl |
---|
| 2 | |
---|
| 3 | # Written by Jessica Hamrick (C) 2010 |
---|
| 4 | |
---|
| 5 | use strict; |
---|
| 6 | use warnings; |
---|
| 7 | |
---|
| 8 | use Net::CUPS; |
---|
| 9 | use Net::CUPS::Destination; |
---|
[7cdd65d] | 10 | use Getopt::Long; |
---|
[78eb866c] | 11 | |
---|
[7cdd65d] | 12 | my $usage = "Usage: gbq [-q QUEUE]\n"; |
---|
[78eb866c] | 13 | |
---|
[7cdd65d] | 14 | my $q = ""; |
---|
| 15 | GetOptions ('q|queue=s' => \$q); |
---|
[78eb866c] | 16 | |
---|
| 17 | if (!$q) { |
---|
[7cdd65d] | 18 | $q = "DEFAULT"; |
---|
[78eb866c] | 19 | } |
---|
| 20 | |
---|
| 21 | my $configpath = "$ENV{'HOME'}/.gutenbach/$q"; |
---|
[85a1ac1] | 22 | if (! -e $configpath) { |
---|
[0d02eca] | 23 | print "Queue '$q' does not exist! Did you forget to add it with 'gutenbach-client-config'?\n"; |
---|
[85a1ac1] | 24 | exit 1; |
---|
| 25 | } |
---|
| 26 | |
---|
[78eb866c] | 27 | my ($host, $queue); |
---|
| 28 | |
---|
| 29 | if (-r $configpath) { |
---|
| 30 | local $/; |
---|
| 31 | my $fh; |
---|
| 32 | open $fh, $configpath; |
---|
| 33 | eval <$fh>; |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | my $cups = Net::CUPS->new(); |
---|
| 37 | $cups->setServer("$host"); |
---|
| 38 | my $printer = $cups->getDestination("$queue"); |
---|
| 39 | |
---|
[9fdf4a1] | 40 | unless( $printer){ |
---|
| 41 | print "Cannot access queue $q...do you have network connectivity and permission to view the queue?\n"; |
---|
| 42 | exit 1; |
---|
| 43 | } |
---|
[78eb866c] | 44 | print "Queue listing for queue '$queue' on '$host'\n\n"; |
---|
[b58aada] | 45 | print "Job ID\t\tOwner\t\tTitle\n"; |
---|
[78eb866c] | 46 | print "-----------------------------------------------------------------\n"; |
---|
| 47 | |
---|
| 48 | my @jobs = $printer->getJobs(0, 0); |
---|
| 49 | my ($job_ref, $jobid); |
---|
| 50 | |
---|
| 51 | foreach $jobid(@jobs) |
---|
| 52 | { |
---|
| 53 | $job_ref = $printer->getJob($jobid); |
---|
| 54 | my $id = $job_ref->{'id'}; |
---|
| 55 | my $user = $job_ref->{'user'}; |
---|
| 56 | my $title = $job_ref->{'title'}; |
---|
| 57 | |
---|
| 58 | print "$id\t\t$user\t\t$title\n"; |
---|
| 59 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.