Hi,
On Tue, 2003-07-15 at 04:36, Knape, Dean wrote:
> I was thinking of adding a line in the printcap that would look something like this:
> filter=( /path/to/filter | /path/to/ifhp $* )
Not sure if this will work, I have never tried it...
>
> The first filter would check if file is postscript then
> while ( <STDIN> )
> { $_ =~ s/^%%Pages:\s+\d+/%%Pages: /;
> print;
> }
This looks OK, however you need to be careful with <STDIN>. As someone
corrected me before, <STDIN> will read up to the next \n character which
can cause problems if your 20MB job doesn't have any returns in it!
This is what I do in these situations (maybe there is a better way to do
it, I'm not sure)
----------- Perl Code START ---------------
use constant LINE_LENGTH => 16384;
my $buf;
my $buf2;
my $sub;
my $eof = 1;
my $check = 1;
while ( read STDIN, $buf, LINE_LENGTH ) {
# match the first character
if ($check and ($buf =~ m/\%/)) {
$buf2 = $buf;
# if line ends in any of required char get next and
append
while (($buf2 =~ m/[%Pages:\s\d]$/) and $eof ) {
unless (read(STDIN, $buf2, LINE_LENGTH)) {
# prevent loop at the end-of-file
$eof = 0;
}
$buf .= $buf2;
}
# check for pattern
if ($buf =~ s/^%%Pages:\s+\d+/%%Pages: /) {
print STDERR "Page count altered\n";
$check = 0;
}
}
print $buf;
}
-------------- Perl Code END -------------
Not perfect, but should work OK provided you don't get too many numbers,
spaces, or any of the matching letters at the end of each read. A better
version would match the pattern progressively, i.e.
m/(%|%P|%Pa|%Pag|<etc><etc>)$/
I hope this helps,
cheers,
sam
>
> and feed this to ifhp.
>
> Is this correct?
>
> The reason for doing this is I use my lprng queues as bounce queues to a print
> manager plus accounting server. Print Manager Plus simply trusts %%Pages: if it has
> a value. If it has no value it will recount.
>
> Thanks,
> Dean
>
> -----------------------------------------------------------------------------
> 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.
> -----------------------------------------------------------------------------
--
CERN, Geneva
IT - Product Support - Unix Infrastructure
E-mail: [EMAIL PROTECTED]
-----------------------------------------------------------------------------
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.
-----------------------------------------------------------------------------