debianmacno-cupsweb
Last change
on this file since a81397c 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
|
Rev | Line | |
---|
[2a2f76c] | 1 | #!/usr/bin/perl |
---|
| 2 | |
---|
| 3 | # Written by Jessica Hamrick (C) 2010 |
---|
| 4 | |
---|
| 5 | use strict; |
---|
| 6 | use warnings; |
---|
| 7 | |
---|
[a81397c] | 8 | use Net::CUPS; |
---|
| 9 | use Net::CUPS::Destination; |
---|
| 10 | |
---|
[2a2f76c] | 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"; |
---|
[85a1ac1] | 22 | if (! -e $configpath) { |
---|
| 23 | print "Queue '$q' does not exist!\n"; |
---|
| 24 | exit 1; |
---|
| 25 | } |
---|
| 26 | |
---|
[2a2f76c] | 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") { |
---|
[c5a98db] | 39 | @args = ("cancel", "-a", "$queue"); |
---|
[2a2f76c] | 40 | } |
---|
[a81397c] | 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 | } |
---|
[2a2f76c] | 49 | else { |
---|
[c5a98db] | 50 | @args = ("cancel", "$id", "$queue"); |
---|
[2a2f76c] | 51 | } |
---|
[c5a98db] | 52 | $ENV{CUPS_SERVER}="$host"; |
---|
[2a2f76c] | 53 | exec (@args) or die "Couldn't execute cancel command"; |
---|
Note: See
TracBrowser
for help on using the repository browser.