debianmacno-cupsweb
Last change
on this file since 38388ac was
38388ac,
checked in by Jessica B. Hamrick <jhamrick@…>, 15 years ago
|
Add support for pathname expansion/multiple files in gbr.
|
-
Property mode set to
100755
|
File size:
892 bytes
|
Rev | Line | |
---|
[fe74c7c] | 1 | #!/usr/bin/perl |
---|
| 2 | |
---|
| 3 | # Written by Jessica Hamrick (C) 2010 |
---|
| 4 | |
---|
| 5 | use strict; |
---|
| 6 | use warnings; |
---|
| 7 | |
---|
[38388ac] | 8 | my $usage = "Usage: gbr QUEUE FILES\n"; |
---|
[fe74c7c] | 9 | |
---|
| 10 | my $q = $ARGV[0]; |
---|
[38388ac] | 11 | my @files = @ARGV[1 .. $#ARGV]; |
---|
[fe74c7c] | 12 | |
---|
[38388ac] | 13 | if (!$q or !@files) { |
---|
[fe74c7c] | 14 | print $usage; |
---|
| 15 | exit 1 |
---|
| 16 | } |
---|
| 17 | |
---|
| 18 | my $configpath = "$ENV{'HOME'}/.gutenbach/$q"; |
---|
[85a1ac1] | 19 | if (! -e $configpath) { |
---|
| 20 | print "Queue '$q' does not exist!\n"; |
---|
| 21 | exit 1; |
---|
| 22 | } |
---|
| 23 | |
---|
[fe74c7c] | 24 | my ($host, $queue); |
---|
| 25 | |
---|
| 26 | if (-r $configpath) { |
---|
| 27 | local $/; |
---|
| 28 | my $fh; |
---|
| 29 | open $fh, $configpath; |
---|
| 30 | eval <$fh>; |
---|
| 31 | } |
---|
| 32 | |
---|
[c5a98db] | 33 | $ENV{CUPS_SERVER}="$host"; |
---|
| 34 | |
---|
[38388ac] | 35 | foreach my $file(@files) { |
---|
| 36 | if ($file =~ m|http://www\.youtube\.com/watch\?v=|) { |
---|
| 37 | open(LP, "|-", "lp", "-d$queue") or die "Couldn't execute lp command"; |
---|
| 38 | print LP "$file"; |
---|
| 39 | close LP; |
---|
| 40 | } |
---|
| 41 | else { |
---|
| 42 | my $pid = open(LP, "-|"); |
---|
| 43 | if (not $pid) { |
---|
| 44 | my @args = ("lp", "-d$queue", "$file"); |
---|
| 45 | exec(@args) or die "Couldn't execute lp command"; |
---|
| 46 | } |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | print "Sent job '$file'\n"; |
---|
[c5a98db] | 50 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.