source: client/bin/gbrm @ 38388ac

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
5use strict;
6use warnings;
7
8use Net::CUPS;
9use Net::CUPS::Destination;
10
11my $usage = "Usage: gbq QUEUE ID\n";
12
13my $q = $ARGV[0];
14my $id = $ARGV[1];
15
16if (!$q or !$id) {
17    print $usage;
18    exit 1
19}
20
21my $configpath = "$ENV{'HOME'}/.gutenbach/$q";
22if (! -e $configpath) {
23    print "Queue '$q' does not exist!\n";
24    exit 1;
25}
26
27my ($host, $queue);
28
29if (-r $configpath) {
30    local $/;
31    my $fh;
32    open $fh, $configpath;
33    eval <$fh>;
34}
35
36my @args;
37
38if ($id eq "all") {
39    @args = ("cancel", "-a", "$queue");
40}
41elsif ($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}
49else {
50    @args = ("cancel", "$id", "$queue");
51}
52$ENV{CUPS_SERVER}="$host";
53exec (@args) or die "Couldn't execute cancel command";
Note: See TracBrowser for help on using the repository browser.