Changeset fc8707b for client/bin/gbr


Ignore:
Timestamp:
Oct 2, 2010, 9:20:02 PM (14 years ago)
Author:
Jessica B. Hamrick <jhamrick@…>
Branches:
master, debian, mac, no-cups
Children:
a5cf43b
Parents:
6b7441a
git-author:
Jessica B. Hamrick <jhamrick@…> (10/02/10 21:20:02)
git-committer:
Jessica B. Hamrick <jhamrick@…> (10/02/10 21:20:02)
Message:
Add '-hhelp' flags to all the client scripts
Add a '-ddryrun' option to gbr, to just list what would be done instead of doing it
File:
1 edited

Legend:

Unmodified
Added
Removed
  • client/bin/gbr

    r6b7441a rfc8707b  
    1212use Image::ExifTool qw(ImageInfo);
    1313
    14 my $usage = "Usage: gbr QUEUE FILES\n";
     14# the usage for this script
     15my $usage = <<USAGE;
     16Usage: gbr [options] [-q QUEUE] FILES
    1517
     18        -q, --queue             Specify a queue other than the default
     19        -d, --dryrun            Just list what would be done
     20        -h, --help              Print this message
     21USAGE
     22
     23# initialize the variables for the options
    1624my $q = "";
    17 GetOptions ('q|queue=s' => \$q);
     25my $dryrun = 0;
     26my $help = 0;
     27
     28# parse the options
     29GetOptions ('q|queue=s' => \$q,
     30            'd|dryrun' => \$dryrun,
     31            'h|help' => \$help);
     32
     33# if the -h flag was passed, then print the usage and exit
     34if ($help) {
     35    print $usage;
     36    exit 0;
     37}
    1838
    1939my @files = @ARGV[0 .. $#ARGV];
     
    6181# if $printer is not defined, then throw an error
    6282unless( $printer){
    63     print "Cannot access queue $q...do you have network connectivity and permission to view the queue?\n";
     83    print "Cannot access queue $q... do you have network connectivity and permission to view the queue?\n";
    6484    exit 1;
    6585}
     
    100120    }
    101121
    102     # send the print job, given the file and the job title
    103     $jobid = $printer->printFile($file, $title);
    104    
    105     # if the printFile command returned a job id, then print that out
    106     # for the user to see
    107     if ($jobid) {
    108         print "Sent job '$title' (id $jobid)\n";
    109     }
     122    # unless it's a dry run, send the print job, given the file and
     123    # the job title
     124    unless ($dryrun) {
     125        $jobid = $printer->printFile($file, $title);
    110126
    111     # otherwise, let them know that an error occurred
    112     else {
    113         print "Error sending job '$title'\n";
    114     }
     127        # if the printFile command returned a job id, then print that out
     128        # for the user to see
     129        if ($jobid) {
     130            print "Sent job '$title' (id $jobid)\n";
     131        }
     132
     133        # otherwise, let them know that an error occurred
     134        else {
     135            print "Error sending job '$title'\n";
     136        }
     137
     138    # otherwise, just print what we would do
     139    } else {
     140        print "Would send file '$file' with title '$title'\n";
     141    }   
    115142}
Note: See TracChangeset for help on using the changeset viewer.