> From [EMAIL PROTECTED] Fri Mar 12 11:12:35 2004
> To: <[EMAIL PROTECTED]>
> Subject: LPRng: Fixing a Windows bug with LPRng?
> From: <[EMAIL PROTECTED]>
> Date: Fri, 12 Mar 2004 19:26:01 +0100
>
>
> Hi,
>
> I'm having a bit of an issue with our printers in a so far Windows-only
> environment, and I thought LPRng might be able to help, due to its
> capabilities regarding filtering of remote print jobs.
>
> Current situation:
> We are having issues related to print jobs that originate from a
> MS-Windows 2000 Terminal Server - the outbin selection does not always
> work as expected, causing one of our applications to crash whenever the
> user attempts to print. It works ok as long as the standard outbin is
> selected.
>                                                      [printer]
>                                                          |
> [Windows Box]-----------------LPD----------------->[Lexmark Box]
>                                                          |
>                                                      [printer1]
>
>
> Planned solution:
>                                                      [printer]
>                                                          |
> [Windows Box]--LPD-->[Linux Box with lprng]--LPD-->[Lexmark Box]
>                                                          |
>                                                      [printer1]
>
>
> Background:
> The items labeled "[Lexmark Box]" are embedded print servers supporting
> LPR/LPD printing via IP and port name ("printer" for the first printer,
> "printer1" for the second).
> Each printer is a Lexmark Optra S 1855 with three additional outbins
> installed.
>
>
> As you can see, I would like to plug a Linux box running LPRng between
> the Windows print server and the Lexmark Boxes, which would run a
> filter script changing the PJL command "@PJL SET OUTBIN = UPPER" to
> "@PJL SET OUTBIN = OPTIONALOUTBINn" (n ranging from 1 to 3).
>
> I believe I have a simple perl script capable of doing this, but what
> I'm still looking for is a printcap entry that avoids unneccessary
> maintenance on the Linux side, as we have approximately 40 Lexmark
> Boxes.
> What I would like to do is pass the IP of the target box, the
> destination printer (printer or printer1), and the destination tray in
> the printer name, and have LPRng sort it out, so I don't have to edit
> /etc/printcap whenever a new box gets installed.
>
> Example: Printjob from Windows goes to
> linux.machine.my.net:lexbox1-printer1-tray3 and LPRng should know that
> it needs to pass "tray3" to the filter, and send the output of the
> filter to lexbox1:printer1.
>
> I know there are some really fancy things that you can do with wildcards
> and variables, but I'm kinda stuck here.
>
> I seem to remember that LPRng's lpr command supports direct printing to
> remote hosts by passing [EMAIL PROTECTED], but I'm not sure as I've never
> used that feature before.
> So, a quick and dirty hack might be to use * as printer name and
> dev/null as output device in the printcap, expand my filter script so
> it derives the necessary information from the name it gets passed, and
> have the filter script issue a lpr [EMAIL PROTECTED] afterwards.
> This sounds really ugly though, which is why I haven't tried this yet.
>
> Anyone willing and able to help, any insights, any experiences?
>
> Kind Regards
> Stefan Baur

I thought of about 4 ways to do this,  ranging from simple to
hideously complex.

I assume that you are using SAMBA to interface to the UNIX
system.  If you are, the following needs to be used, as SAMBA
does not support 'wildcard' printers:

PRINTCAP:

.common:sd=/var/spool/lpd/%P:filter=/usr/local/libexec/ifhp 

lexbox1-printer1-tray1:tc=.common:lp=printer1
  :ifhp=model=hp4,outbin=tray1
lexbox1-printer1-tray2:tc=.common:lp=printer1
  :ifhp=model=hp4,outbin=tray2
lexbox1-printer1-tray3:tc=.common:lp=printer1
  :ifhp=model=hp4,outbin=tray3

lexbox1-printer2-tray1:tc=.common:lp=printer2
  :ifhp=model=hp4,outbin=tray1
lexbox1-printer2-tray2:tc=.common:lp=printer2
  :ifhp=model=hp4,outbin=tray2
lexbox1-printer2-tray3:tc=.common:lp=printer2
  :ifhp=model=hp4,outbin=tray3

printer1:tc=.common:lp=192.168.1.1%9100
  :ifhp=model=hp4

printer2:tc=.common:lp=192.168.1.2%9100
  :ifhp=model=hp4

This is the simplest method.  Lets see how it works.

You either create (or let SAMBA create) a print queue on your Windows system
with the appropriate name.  Then you print the job to the queue.

When the job arrives at the LPD server, it is first put into the
print queue for 'lexbox1-printer1-tray1' or whatever you chose.
Then the LPD server will 'forward' the job to the 'printer1' queue.
But before it does, it invokes the 'ifhp' program which will add the
appropriate 'outbin' values to the job.

An alternative to this is to use:

lexbox1-printer1
        |lexbox1-printer1-*:
    :tc=.common:lp=192.168.1.1%9100
    :ifhp=model=hp4
    :incoming_control_filter=/usr/local/libexec/fixup

The 'fixup' filter will append the appropriate 'Z' option value
for IFHP onto the control file.

#!/usr/bin/perl

my $printer = $ARGV{'PRINTER'};
my $tray = "";
$tray = "";
$tray = "outbin=upper" if( $printer =~ /tray1/ );
$tray = "outbin=middle" if( $printer =~ /tray2/ );
$tray = "outbin=lower" if( $printer =~ /tray3/ );
while( <> ){
        chomp;
        if( /^Z/ ){
                $_ .= ",$tray";
                $tray = "";
        }
        print $_ . "\n";
}
if( $tray ){
        print "-Z$tray\n";
}
exit 0;

If you do not want to use IFHP,  then modification of the 'fixup' filter is left
as an execise for the student :-)

Patrick Powell

Patrick Powell                 Astart Technologies
[EMAIL PROTECTED]            6741 Convoy Court
Network and System             San Diego, CA 92111
  Consulting                   858-874-6543 FAX 858-751-2435
LPRng - Print Spooler (http://www.lprng.com)

-----------------------------------------------------------------------------
YOU MUST BE A LIST MEMBER IN ORDER TO POST TO THE LPRNG MAILING LIST
The address you post from MUST be your subscription address

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