Changeset 6b7441a for client/bin/gbq


Ignore:
Timestamp:
Oct 2, 2010, 8:53:02 PM (14 years ago)
Author:
Jessica B. Hamrick <jhamrick@…>
Branches:
master, debian, mac, no-cups
Children:
fc8707b
Parents:
814d4f8
git-author:
Jessica B. Hamrick <jhamrick@…> (10/02/10 20:53:02)
git-committer:
Jessica B. Hamrick <jhamrick@…> (10/02/10 20:53:02)
Message:

Add comments to the client scripts.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • client/bin/gbq

    r9dee329 r6b7441a  
    11#!/usr/bin/perl
    22
    3 # Written by Jessica Hamrick (C) 2010
     3# This script was largely written by Jessica Hamrick (jhamrick), with
     4# help from Kyle Brogle (broglek)
    45
    56use strict;
     
    1516GetOptions ('q|queue=s' => \$q);
    1617
     18# if the -q option is not specified, then assume we're using the
     19# default queue
    1720if (!$q) {
    1821    $q = "DEFAULT";
    1922}
    2023
     24# set configuration path, and complain if it doesn't exist
    2125my $configpath = "$ENV{'HOME'}/.gutenbach/$q";
    2226if (! -e $configpath) {
     
    2529}
    2630
     31# initialize the host and queue variables: host holds the address for
     32# the machine on which the remote queue runs, and queue holds the name
     33# of the printer
    2734my ($host, $queue);
    2835
     36# load the configuration file (this will set $host and $queue)
    2937if (-r $configpath) {
    3038    local $/;
     
    3442}
    3543
     44# initialize a new CUPS session
    3645my $cups = Net::CUPS->new();
     46# set the server to the one specified in the config file
    3747$cups->setServer("$host");
     48# set the printer name to the one specified in the config file
    3849my $printer = $cups->getDestination("$queue");
    3950
     51# if $printer is not defined, then throw an error
    4052unless( $printer){
    4153    print "Cannot access queue $q...do you have network connectivity and permission to view the queue?\n";
    4254    exit 1;
    4355}
     56
     57# print pretty headings and stuff
    4458print "Queue listing for queue '$queue' on '$host'\n\n";
    4559printf ("%-8s%-15s%s\n","Job","Owner","Title");
    4660print "-"x70 . "\n";
     61
     62# get the list of jobs from the printer
    4763my @jobs = $printer->getJobs(0, 0);
     64
     65# initialize the job reference and job id variables
    4866my ($job_ref, $jobid);
    4967
     68# for each job in the list of jobs:
    5069foreach $jobid(@jobs)
    5170{       
    52         $job_ref = $printer->getJob($jobid);
    53         my $id = $job_ref->{'id'};
    54         my $user = $job_ref->{'user'};
    55         my $title = $job_ref->{'title'};
     71    # get the reference to the job (so we can get various related
     72    # variables)
     73    $job_ref = $printer->getJob($jobid);
    5674
    57         printf ("%-8s%-15s%s\n","$id",substr("$user",0,15),substr("$title",0,47));
     75    # get the id of the job
     76    my $id = $job_ref->{'id'};
     77    # get the user who printed the job
     78    my $user = $job_ref->{'user'};
     79    # get the title of the job
     80    my $title = $job_ref->{'title'};
     81   
     82    # print the job information to the screen
     83    printf ("%-8s%-15s%s\n","$id",substr("$user",0,15),substr("$title",0,47));
    5884}
Note: See TracChangeset for help on using the changeset viewer.