Changeset 6b7441a for client/bin/gbr
- Timestamp:
- Oct 2, 2010, 8:53:02 PM (14 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/gbr
r600e713 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; … … 18 19 my @files = @ARGV[0 .. $#ARGV]; 19 20 21 # if the -q option is not specified, then assume we're using the 22 # default queue 20 23 if (!$q){ 21 24 $q = "DEFAULT"; 22 25 } 26 27 # if there are no files specified to print, then show the usage, 28 # because the user is Doing It Wrong 23 29 if (!@files) { 24 30 print $usage; … … 26 32 } 27 33 34 # set configuration path, and complain if it doesn't exist 28 35 my $configpath = "$ENV{'HOME'}/.gutenbach/$q"; 29 36 if (! -e $configpath) { … … 32 39 } 33 40 41 # initialize the host and queue variables: host holds the address for 42 # the machine on which the remote queue runs, and queue holds the name 43 # of the printer 34 44 my ($host, $queue); 35 45 46 # load the configuration file (this will set $host and $queue) 36 47 if (-r $configpath) { 37 48 local $/; … … 41 52 } 42 53 54 # initialize a new CUPS session 43 55 my $cups = Net::CUPS->new(); 56 # set the server to the one specified in the config file 44 57 $cups->setServer("$host"); 58 # set the printer name to the one specified in the config file 45 59 my $printer = $cups->getDestination("$queue"); 60 61 # if $printer is not defined, then throw an error 46 62 unless( $printer){ 47 63 print "Cannot access queue $q...do you have network connectivity and permission to view the queue?\n"; 48 64 exit 1; 49 65 } 66 67 # initialize the job id and title variables for use below 50 68 my ($jobid, $title); 51 69 70 # for each file that the user wants to print 52 71 foreach my $file(@files) { 72 73 # check to see if the file is a youtube video. If it is, then 74 # write the URL to a temporary file, and set the number of copies 75 # on the print job to 42 (this is the dirty hack we have in place 76 # to indicate that the job is a youtube file instead of a normal 77 # file) 53 78 if ($file =~ m|http://www\.youtube\.com/watch\?v=|) { 54 79 open FILE, ">", "/tmp/gutenbach-youtube" or die "Couldn't create temporary file"; … … 58 83 $printer->addOption("copies", 42); 59 84 } 85 86 # otherwise, we assume it's a normal file. Try to use exiftool's 87 # ImageInfo to find out the tag information about the file (i.e., 88 # title, artist, and album). If you can, then rename the job to 89 # reflect those tags. Otherwise, keep the normal title. 60 90 else { 61 91 my $fileinfo = ImageInfo($file); … … 70 100 } 71 101 102 # send the print job, given the file and the job title 72 103 $jobid = $printer->printFile($file, $title); 73 104 105 # if the printFile command returned a job id, then print that out 106 # for the user to see 74 107 if ($jobid) { 75 108 print "Sent job '$title' (id $jobid)\n"; 76 109 } 110 111 # otherwise, let them know that an error occurred 77 112 else { 78 113 print "Error sending job '$title'\n";
Note: See TracChangeset
for help on using the changeset viewer.