debianmacno-cupsweb
Last change
on this file since 38388ac was
a81397c,
checked in by Jessica B. Hamrick <jhamrick@…>, 14 years ago
|
Added the "current" option to gbrm, which just removes the current job from the queue.
|
-
Property mode set to
100755
|
File size:
950 bytes
|
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 | |
---|
11 | my $usage = "Usage: gbq QUEUE ID\n"; |
---|
12 | |
---|
13 | my $q = $ARGV[0]; |
---|
14 | my $id = $ARGV[1]; |
---|
15 | |
---|
16 | if (!$q or !$id) { |
---|
17 | print $usage; |
---|
18 | exit 1 |
---|
19 | } |
---|
20 | |
---|
21 | my $configpath = "$ENV{'HOME'}/.gutenbach/$q"; |
---|
22 | if (! -e $configpath) { |
---|
23 | print "Queue '$q' does not exist!\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 @args; |
---|
37 | |
---|
38 | if ($id eq "all") { |
---|
39 | @args = ("cancel", "-a", "$queue"); |
---|
40 | } |
---|
41 | elsif ($id eq "current") { |
---|
42 | my $cups = Net::CUPS->new(); |
---|
43 | $cups->setServer("$host"); |
---|
44 | my $printer = $cups->getDestination("$queue"); |
---|
45 | my @jobs = $printer->getJobs(0, 0); |
---|
46 | my $id = $jobs[0]; |
---|
47 | @args = ("cancel", "$id", "$queue"); |
---|
48 | } |
---|
49 | else { |
---|
50 | @args = ("cancel", "$id", "$queue"); |
---|
51 | } |
---|
52 | $ENV{CUPS_SERVER}="$host"; |
---|
53 | exec (@args) or die "Couldn't execute cancel command"; |
---|
Note: See
TracBrowser
for help on using the repository browser.