Need a printer filter to change bins
Harold Tomlinson
haroldt at paralandra.yorku.ca
Thu Feb 21 09:40:38 AEST 1991
>> I've just set up a new printer on our Unix system (using the BSD
>> printer package) and want to set it up so that jobs sent to this
>> printer will select one bin for their banner page (with yellow
>> paper in it) and another bin for the rest of the printing. Is this
>> done using an output filter (of) or an input filter (if)? Does anyone
yes. (No, really, the answer is yes.) If you wish, write your printer filter
to take standard input, prepend a command to change bins, grab the header
page (if it exists) and change bins again. Then grab the rest of the
standard in and dump the entire thing to standard out.
On you /etc/printcap the of and if entries will be the same shell script.
Then lpr will send the print job to the stdin of the filter and take the
stdout and print it.
The hard part is determining if there is a header page and pulling that
off.
>> have a printer filter template that I could modify for this purpose.
No.
>> I just need to insert the code to output the escape sequences to
>> switch the bins but don't know what the structure of a filter program
>> for this sort of purpose is. Thanks in advance.
As an example, here is a postscript filter that I started to play with...
------------------------------cut here-----------------------------------
#!/bin/sh
# output header page in postscript
pssetup="%!
gsave
35 9.3 80 mul translate
/basic 8 def
/normal /Courier findfont basic scalefont def
/down { 0 basic neg rmoveto } def
/p { normal setfont show } def
/n { currentpoint exch pop 0 exch moveto down } def
0 0 moveto"
while read line;
do
case $line in
*%!*) break;;
*) pssetup="$pssetup
($line) p n";;
esac;
done
pssetup="$pssetup
showpage
grestore"
echo "$pssetup" | /usr/local/bin/tcp_f -w -e harpy 4099
/usr/local/bin/tcp_f -w -e harpy 4099
-------------------------------------------------------------------------
It has problems and has been cut off due to lack of time.
Basically, it is supposed to look for the "%!" that signifies the start of
the postscript and send that (at one point it looked for the last line of the
header page ie. `grep "*Date:*"`). Mine then pumps the output through
another program tcp_f.
For what you want, change the last two lines to
-------------------------------------------------
echo "$pssetup"
while read line
echo "$line"
done
-------------------------------------------------
>> Peter Steele Acadia Univ. Canada B0P 1X0 peter at auad.AcadiaU.CA
>> Software Analyst Wolfville, NS 902-542-2201x121 peter at Acadia.BITNET
Oh, what the heck... try this:
------------------------------------------------------------------------
------------------------------------------------------------------------
---- create the following file, call it /usr/local/lib/lp_trayswap -----
------------------------------------------------------------------------
#!/bin/sh
# output header page on paper from other bin
###NOTE:: define changetobinone and changetobintwo, these numbers are bogus
changetobintwo="270312"
changetobinone="270311"
pssetup="$changetobintwo
"
while read line;
do
case $line in
*Date:*) break;;
*) pssetup="$pssetup
$line";;
esac;
done
pssetup="$pssetup
$line
$changetobinone"
echo "$pssetup"
while read line;
do
echo "$line
";
done
------------------------------------------------------------------------
------------------------------------------------------------------------
------------------------------------------------------------------------
----- add the following entry to your /etc/printcap --------------------
ccslaser|laser:\
:lp=/dev/lp:\
:sd=/usr/spool/lp_lp:\
:of=/usr/local/lib/lp_trayswap:\
:if=/usr/local/lib/lp_trayswap:\
:lf=/usr/spool/lp_lp/log:\
:af=/usr/spool/lp_lp/acct:\
:pl#66:\
:pw#80:\
:mc#20:\
:mx#0:
------------------------------------------------------------------------
------------------------------------------------------------------------
------------------------------------------------------------------------
- be sure to `touch /usr/spool/lp_lp/log; touch /usr/spool/lp_lp/acct` -
------------------------------------------------------------------------
------------------------------------------------------------------------
------------------------------------------------------------------------
Disclaimer::: If you really believe the above might work, I feel sorry for
you. If you try it, :) ... well, I won't be responsible for the actions
of any adult (or simulated adult).
======================================================================
=== Harold Tomlinson ===
== Computing and Communications Services ==
= YORK UNIVERSITY =
= haroldt at paralandra.yorku.ca =
= 416- 736-5257-33802 =
======================================================================
--
======================================================================
=== Harold Tomlinson ===
== Computing and Communications Services ==
= YORK UNIVERSITY =
= haroldt at paralandra.yorku.ca =
= 416- 736-5257-33802 =
======================================================================
More information about the Comp.unix.questions
mailing list