source: client/bin/gbq @ 600e713

debianmacno-cups
Last change on this file since 600e713 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
RevLine 
[78eb866c]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;
[7cdd65d]10use Getopt::Long;
[78eb866c]11
[7cdd65d]12my $usage = "Usage: gbq [-q QUEUE]\n";
[78eb866c]13
[7cdd65d]14my $q = "";
15GetOptions ('q|queue=s' => \$q);
[78eb866c]16
17if (!$q) {
[7cdd65d]18    $q = "DEFAULT";
[78eb866c]19}
20
21my $configpath = "$ENV{'HOME'}/.gutenbach/$q";
[85a1ac1]22if (! -e $configpath) {
[0d02eca]23    print "Queue '$q' does not exist!  Did you forget to add it with 'gutenbach-client-config'?\n";
[85a1ac1]24    exit 1;
25}
26
[78eb866c]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");
39
[9fdf4a1]40unless( $printer){
41    print "Cannot access queue $q...do you have network connectivity and permission to view the queue?\n";
42    exit 1;
43}
[78eb866c]44print "Queue listing for queue '$queue' on '$host'\n\n";
[9dee329]45printf ("%-8s%-15s%s\n","Job","Owner","Title");
46print "-"x70 . "\n";
[78eb866c]47my @jobs = $printer->getJobs(0, 0);
48my ($job_ref, $jobid);
49
50foreach $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
[9dee329]57        printf ("%-8s%-15s%s\n","$id",substr("$user",0,15),substr("$title",0,47));
[78eb866c]58}
Note: See TracBrowser for help on using the repository browser.