> From [EMAIL PROTECTED] Wed Sep 13 01:58:12 2000
> Date: Wed, 13 Sep 2000 09:47:05 +0300 (EEST)
> From: Pekka Savola <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: LPRng: Setting ifhp -Z options from lpr -Q.
>
> Hello all,
>
> We're using printer aliases (printcap is like
> printer|printer-2s|printer-a3|...) to make sure older/Windows clients can
> print duplex and other special modes gracefully.
>
> When I implemented this in LPRng, I had to create a special 20-line
> wrapper for ifhp that'd see if there were any printer name specials in -Q
> strings, and change them to corresponding ifhp -Z options.
>
> Are there easier or _better_ ways to do this?
>
> -- 
> Pekka Savola                 "Tell me of difficulties surmounted, 
> [EMAIL PROTECTED]      not those you stumble over and fall"

Well... no EASIER or BETTER,  but there are DIFFERENT ways to do this.

Currently,  my favored way is to use the 'incoming_control_filter'
to get the 'Q name' and convert them to 'Z' options:

#!/usr/bin/perl
# update_z script:
# Determine the options according to the format of the queue name
#  Inspired by the psfilter code of Andreas Klemm
#  and Thomas Bueschgens 
# First, get command line arguments
#
use Getopt::Std;
my(%args,$Q,$Zopts,@file);
getopts(
"A:B:C:D:E:F:G:H:I:J:K:L:M:N:O:P:Q:R:S:T:U:V:W:X:Y:Z:" .
"a:b:cd:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:t:u:v:w:x:y:z:",
\%args );
# read stdin
@file = <STDIN>;
$Zopts = "";
# first use command line Queue name
$Q = $args{"Q"};
if( not $Q and (($Q) = grep(/^Q/,@file)) ){
   # next use control file Queue name
        chomp $Q if $Q;
}
# now we split up the name and use as parameters for Z options
while( $Q =~ /_([^_]+)/g ){
        # you can add them or test and then add them
        if( $1 eq "landscape"
                or $1 eq "legal"
                or $1 eq "ledger" ){
                $Zopts .= ",$1"
        }
}
if( $Zopts ){
        # remove leading comma
        $Zopts = substr( $Zopts, 1 );
        #replace or prefix Z options
        if( not (grep { s/$/,$Zopts/ if /^Z/; } @file) ){
                print "Z" . $Zopts . "\n";
        }
}
print @file if( @file );
exit 0

Patrick Powell                 Astart Technologies,
[EMAIL PROTECTED]            9475 Chesapeake Drive, Suite D,
Network and System             San Diego, CA 92123
  Consulting                   858-874-6543 FAX 858-279-8424 
LPRng - Print Spooler (http://www.astart.com)

-----------------------------------------------------------------------------
If you need help, send email to [EMAIL PROTECTED] (or lprng-requests
or lprng-digest-requests) with the word 'help' in the body.  For the impatient,
to subscribe to a list with name LIST,  send mail to [EMAIL PROTECTED]
with:                           | example:
subscribe LIST <mailaddr>       |  subscribe lprng-digest [EMAIL PROTECTED]
unsubscribe LIST <mailaddr>     |  unsubscribe lprng [EMAIL PROTECTED]

If you have major problems,  send email to [EMAIL PROTECTED] with the word
LPRNGLIST in the SUBJECT line.
-----------------------------------------------------------------------------

Reply via email to