source: client/bin/gbrm @ b58aada

debianmacno-cupsweb
Last change on this file since b58aada was b58aada, checked in by Jessica B. Hamrick <jhamrick@…>, 14 years ago

Use perl bindings for gbr and gbrm in addition to gbq. Update README.

  • Property mode set to 100755
File size: 835 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 $cups = Net::CUPS->new();
37$cups->setServer("$host");
38my $printer = $cups->getDestination("$queue");
39my @jobs = $printer->getJobs(0, 0);
40
41if ($id eq "all") {
42    foreach $id(@jobs) {
43        $printer->cancelJob($id);
44    }
45}
46elsif ($id eq "current") {
47    $id = $jobs[0];
48    $printer->cancelJob($id);
49}
50else {
51    $printer->cancelJob($id);
52}
Note: See TracBrowser for help on using the repository browser.