source: branches/samba-3.0/examples/scripts/printing/cups/smbaddprinter.pl

Last change on this file was 1, checked in by Paul Smedley, 18 years ago

Initial code import

File size: 1.5 KB
Line 
1#!/usr/bin/perl
2## Add printer script for samba, APW, and cups
3## Copyright (C) Jeff Hardy <hardyjm@potsdam.edu> 2004
4##
5## This program is free software; you can redistribute it
6## and/or modify it under the terms of the GNU General
7## Public License as published by the Free Software Foundation;
8## ither version 2 of the License, or (at your option) any
9## later version.
10##
11## This program is distributed in the hope that it will be useful,
12## but WITHOUT ANY WARRANTY; without even the implied warranty of
13## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14## GNU General Public License for more details.
15##
16## You should have received a copy of the GNU General Public
17## License along with this program; if not, write to the Free
18## Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
19## USA.
20
21@argv = @ARGV;
22
23# take in args
24my $lpname=shift(@argv); # printer name
25my $shname=shift(@argv); # share name -> used for CUPS queue name
26my $portname=shift(@argv); # port name
27my $drivername=shift(@argv); # driver name -> used for CUPS description
28my $location=shift(@argv); # location -> used for CUPS device URI
29my $win9x=shift(@argv); # win9x location
30
31#check for location syntax
32#if no protocol specified...
33if ($location !~ m#:/#){
34 #assume an lpd printer
35 $location = "lpd://".$location;
36}
37#else, simply pass the URI on to the lpadmin command
38
39#run the cups lpadmin command to add the printer
40system("/usr/sbin/lpadmin -p $shname -D \"$drivername\" -E -v $location");
41
Note: See TracBrowser for help on using the repository browser.