debianmacno-cups
Last change
on this file since eafb5c5 was
9dee329,
checked in by Kyle Brogle <broglek@…>, 14 years ago
|
[Trac # 17] gbq now has fixed width columns to prevent formatting inconsistencies.
|
-
Property mode set to
100755
|
File size:
1.2 KB
|
Line | |
---|
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; |
---|
10 | use Getopt::Long; |
---|
11 | |
---|
12 | my $usage = "Usage: gbq [-q QUEUE]\n"; |
---|
13 | |
---|
14 | my $q = ""; |
---|
15 | GetOptions ('q|queue=s' => \$q); |
---|
16 | |
---|
17 | if (!$q) { |
---|
18 | $q = "DEFAULT"; |
---|
19 | } |
---|
20 | |
---|
21 | my $configpath = "$ENV{'HOME'}/.gutenbach/$q"; |
---|
22 | if (! -e $configpath) { |
---|
23 | print "Queue '$q' does not exist! Did you forget to add it with 'gutenbach-client-config'?\n"; |
---|
24 | exit 1; |
---|
25 | } |
---|
26 | |
---|
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 | |
---|
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 | } |
---|
44 | print "Queue listing for queue '$queue' on '$host'\n\n"; |
---|
45 | printf ("%-8s%-15s%s\n","Job","Owner","Title"); |
---|
46 | print "-"x70 . "\n"; |
---|
47 | my @jobs = $printer->getJobs(0, 0); |
---|
48 | my ($job_ref, $jobid); |
---|
49 | |
---|
50 | foreach $jobid(@jobs) |
---|
51 | { |
---|
52 | $job_ref = $printer->getJob($jobid); |
---|
53 | my $id = $job_ref->{'id'}; |
---|
54 | my $user = $job_ref->{'user'}; |
---|
55 | my $title = $job_ref->{'title'}; |
---|
56 | |
---|
57 | printf ("%-8s%-15s%s\n","$id",substr("$user",0,15),substr("$title",0,47)); |
---|
58 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.