Changeset 6b7441a for client/bin/gbq
- Timestamp:
- Oct 2, 2010, 8:53:02 PM (15 years ago)
- 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)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
client/bin/gbq
r9dee329 r6b7441a 1 1 #!/usr/bin/perl 2 2 3 # Written by Jessica Hamrick (C) 2010 3 # This script was largely written by Jessica Hamrick (jhamrick), with 4 # help from Kyle Brogle (broglek) 4 5 5 6 use strict; … … 15 16 GetOptions ('q|queue=s' => \$q); 16 17 18 # if the -q option is not specified, then assume we're using the 19 # default queue 17 20 if (!$q) { 18 21 $q = "DEFAULT"; 19 22 } 20 23 24 # set configuration path, and complain if it doesn't exist 21 25 my $configpath = "$ENV{'HOME'}/.gutenbach/$q"; 22 26 if (! -e $configpath) { … … 25 29 } 26 30 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 27 34 my ($host, $queue); 28 35 36 # load the configuration file (this will set $host and $queue) 29 37 if (-r $configpath) { 30 38 local $/; … … 34 42 } 35 43 44 # initialize a new CUPS session 36 45 my $cups = Net::CUPS->new(); 46 # set the server to the one specified in the config file 37 47 $cups->setServer("$host"); 48 # set the printer name to the one specified in the config file 38 49 my $printer = $cups->getDestination("$queue"); 39 50 51 # if $printer is not defined, then throw an error 40 52 unless( $printer){ 41 53 print "Cannot access queue $q...do you have network connectivity and permission to view the queue?\n"; 42 54 exit 1; 43 55 } 56 57 # print pretty headings and stuff 44 58 print "Queue listing for queue '$queue' on '$host'\n\n"; 45 59 printf ("%-8s%-15s%s\n","Job","Owner","Title"); 46 60 print "-"x70 . "\n"; 61 62 # get the list of jobs from the printer 47 63 my @jobs = $printer->getJobs(0, 0); 64 65 # initialize the job reference and job id variables 48 66 my ($job_ref, $jobid); 49 67 68 # for each job in the list of jobs: 50 69 foreach $jobid(@jobs) 51 70 { 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); 56 74 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)); 58 84 }
Note: See TracChangeset
for help on using the changeset viewer.