If this isn't exactly what you wanted, please try our Search (there's a LOT of techy and non-techy stuff here about Linux, Unix, Mac OS X and just computers in general!):
From - Thu Jan 13 06:35:55 2000
Xref: world comp.unix.sco.misc:113866
Path: world!newsfeed.mathworks.com!arclight.uoregon.edu!logbridge.uoregon.edu!nntp.upenn.edu!news.misty.com!shady!shady!not-for-mail
From: kevin@shady.com (Kevin Smith, ShadeTree Software, Inc.)
Newsgroups: comp.unix.sco.misc
Subject: Re: print filters
Date: 12 Jan 2000 22:58:22 -0500
Organization: ShadeTree Software, Inc.
Lines: 160
Message-ID: <85jigu$b41@shady.shady.com>
References: <38797A88.423347FF@squonk.net> <85d0sl$a5k@shady.shady.com> <387B2968.C656F3CE@squonk.net>
NNTP-Posting-Host: localhost.shady.com
X-Mozilla-Status: 8010
X-Mozilla-Status2: 00000000
In article <387B2968.C656F3CE@squonk.net> "Brian K. White" <linut@squonk.net> writes:
>Kevin Smith wrote:
>>
>> In article <38797A88.423347FF@squonk.net> "Brian K. White" <linut@squonk.net> writes:
...
>
>Right. per someone elses response, I did this and it works. thanks.
>However now it seems I want still more :)
>
>I have a program (not an important one for me, QCAD, gpl cad/drawing app) that
>just spits out ps data to the printer you pick (it has an option to print to
>file, and of course, since it's gpl and I compiled it myself, I could twiddle
>the source, but I'm looking for a real solution) so I set up another printer
>named ps4 that uses that same physical printer as p4, but I changed the
>printer interface so that the default filter was ps2epson instead of lp.cat.
>The idea was to pick "ps4" from inside the app and have graphics come out of
>the physical printer p4.
>text came out. here is what I did:
>
>I changed this:
>-------------------
>#Set up the default filter.
>if [ -x "${LOCALPATH}/lp.cat" ]
>then
> LPCAT="${LOCALPATH}/lp.cat 0"
>else
> LPCAT="cat"
>fi
>
>#If we are not using a filter, use the default one.
>if [ -z "${FILTER}" ]
>then
> FILTER="${LPCAT}"
>fi
>
>
>to this:
>------------------
>LPCAT="${LOCALPATH}/ps2epson"
>FILTER="${LPCAT}"
>
>
>there is a ps2epson script in $LOCALPATH which at that point is
>/usr/spool/lp/bin
>
>but I don't see where $FILTER or $LPCAT are even used.
>
>actually a few other apps just make the ps assumption too and if this worked
>that would be the best barring either getting magical detection of content
>type by the
>spooler, or getting a real ps printer.
You don't say the source of the interface program. If $FILTER or $LPCAT
are not used just don't bother with them and put your ps2epson whereever
the 'cat' is.
You could also add postscript processing to p4 as an option (-ops).
This is what I do for a laser printer.
At the top of the interface program...
GS=/usr/local/bin/gs
GSOPTS="-q -sDEVICE=ljet3 -dNOPAUSE"
Further down...
...
options=$5
shift; shift; shift; shift; shift
mode=auto
init=_init
for o in $options
do
case $o in
raw|g*)
mode=raw
init=_init_raw
;;
2c)
mode=2c
init=_init_2c
;;
ps)
mode=ps
init=_init_raw
;;
esac
done
Then in the actual print loop
{
# set printer width
# send the file(s) to the standard out $copies times
while [ "$copies" -gt 0 ]
do
# Initialize the printer
$init
for file
do
case $mode in
raw)
cat "$file"
;;
2c)
...
;;
ps)
$GS $GSOPTS -sOUTPUTFILE=- "$file" </dev/null
;;
auto|*)
...
esac
done
done
} | ... cat/netcat/whatever
Postscript output all starts with something like
%!PS-Adobe-3.0
You could read and check the first line to autodetect.
Maybe something like (totally untested mind you)
ps=`line` (this should work since stdin is the file`
case "$ps" in
'$!PS-Adobe'*)
(
echo "$ps"
cat
) | ghostscript...
;;
*)
echo "$ps"
cat
;;
esac
And finially and most importantly, you can't have to printers to the same
device. Each queue is independent and you will mix output if you
are going to a serial or parallel devices. It should work with network
printers as they normally only allow one connection at a time.
Normally though, I've found it best to do one of two things.
1) Handle every possibility in one interface script with -o options.
2) Create an interface script for each option but funnel them all
through one final printer. I.e. each script does
{
... cat file ... whatever
} | lp -dprinter
The 'printer' interface can be totally dumb and just pass the job
through or can take -oraw as a signal to pass stuff through
untouched.
--
Do two rights make | Kevin Smith, ShadeTree Software, Philadelphia, PA, USA
a libertarian | 001-215-487-3811 shady.com,kevin bbs.cpcn.com,sysop
| dvtug.org,kevins--Deleware Valley Transit Users Group
Enter your email address for automatic notification of new posts here
(be sure to whitelist 'feedburner.com' if you use spam filtering)
| Views for this page | ||||
|---|---|---|---|---|
| Today | This Week | This Month | This Year | Overall |
| 3 | 4 | 16 | 171 | 1,056 |
/Bofcusm/235.html copyright 1997-2004 (various authors) All Rights Reserved
Have you tried Searching this site?
Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates
This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.

Add your comments