Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 Oct 2011 03:42:22 -0700 (PDT)
From:      Bill Tillman <btillman99@yahoo.com>
To:        "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org>
Subject:   Re: Fast personal printing _without_ CUPS
Message-ID:  <1319712142.89939.YahooMailNeo@web36507.mail.mud.yahoo.com>
In-Reply-To: <15996.1319704110@tristatelogic.com>
References:  <15996.1319704110@tristatelogic.com>

next in thread | previous in thread | raw e-mail | index | archive | help
=0A=0A=0A=0A________________________________=0AFrom: Ronald F. Guilmette <r=
fg@tristatelogic.com>=0ATo: freebsd-questions@freebsd.org=0ASent: Thursday,=
 October 27, 2011 4:28 AM=0ASubject: Fast personal printing _without_ CUPS=
=0A=0A=0A=0AThis isn't really a question.=A0 It's more of a semi-rant, comb=
ined with some=0Ainformation that I wanted to put on the record (so that it=
 can be googled)=0Abecause it may benefit some folks, other than just me.=
=0A=0AI'm impatient by nature, and I don't like CUPS.=A0 (I would say that =
I hate=0Ait, but I don't actually feel that strongly.)=0A=0AI have two pers=
onal workstations.=A0 When I say "personal" I mean it.=A0 I'm=0Athe only on=
e who ever touches them.=0A=0AOne of them I have been bringing back up rece=
ntly after a long hiatus,=0Aand I've just installed 8.2-RELEASE/amd64 on it=
.=0A=0AOne of the first things I found I needed to do with it, after instal=
ling=0Athe OS and a bunch of my favorite ports & packages was to set it up =
for=0Aprinting to a crusty/trusty old workhorse... an HP Laserjet 3015.=A0 =
(This=0Aprinter can print both plain text and Postscript, but if I just sen=
d=0Ait plain text the output doesn't really suit me, so I've made it pretti=
er.=0ASee below.)=0A=0ABecause I've never used 8.2 before... or even any 8.=
x release, I naturally=0Awent into the Handbook and looked for _current_ gu=
idance on setting up=0Aprinters.=A0 Most of that information was quite help=
ful, right up to the point=0Awhere it started discussing CUPS.=0A=0AThe bot=
tom line is that CUPS is sophisticated, which is to say complex and=0Aconvo=
luted.=A0 If you are impatient, then setting up CUPS properly is both=0Ated=
ious and time consuming.=A0 Of course, it _is_ essential that you properly=
=0Aset up CUPS if you are setting up a _server_ that multiple people will u=
se,=0Abut for a personal workstation, the entire queueing structure is just=
 overkill,=0Ain my opinion.=0A=0AMore importantly, CUPS, for me at least, s=
eems to be quite slow.=A0 There's a=0Aloooooooong pause after I queue somet=
hing for printing until something actually=0Acomes out of the printer.=A0 M=
aybe that's my fault, e.g. because I didn't con-=0Afigure CUPS correctly, a=
nd maybe it isn't.=A0 I don't know, and actually, I=0Adon't want to know, b=
ecause I found a way to nicely print stuff that just=0Abypasses CUPS entire=
ly.=A0 And it works for me, so I am a happy camper.=0A=0AI just wanted to s=
hare what I did.=0A=0AIn a nutshell, I moved/renamed /usr/bin/lpr to /usr/b=
in/lpr- and replaced=0Ait with this trivial script:=0A=0A=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A#!/bin/sh=0A=
=0Aprinter=3D'/dev/ulpt0'=0A=0Aif [ $# =3D 0 ]; then=0A=A0 cat | /usr/local=
/libexec/psif > $printer=0Aelse=0A=A0 for arg in $* ; do=0A=A0 =A0 cat $arg=
 | /usr/local/libexec/psif > $printer=0A=A0 done=0Afi=0A=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=0AMy Laserj=
et 3015 used to be hooked up via a good old fashioned bulky "centronix"=0Ap=
arallel cable, but I thought that I ought to finally get myself into this=
=0Acentury, so I got a new USB 2.0 cable for it just the other day, and now=
 it's=0Aname is "/dev/ulpt0" rather than "/dev/lpt0" as before.=0A=0AAs you=
 can see, the script above just takes whatever filnames are given on=0Athe =
cmmand line and cats them one-by-one through psif and then the output=0Afro=
m that gets sent straight to /dev/ulpt0.=0A=0AOne little snag though... as =
I found out, it doesn't matter if you try to=0Aset the SUID bit on this scr=
ipt and make it owned by root.=A0 Nowadays shell=0Ascripts simply do not do=
 SUID anymore.=A0 The only reason that's even signifi-=0Acant is that you'l=
l probably want to be able to print while logged in as=0Aany old user, and =
in order to make that work with this scheme, you have to do:=0A=0A=A0  chmo=
d 0666 /dev/ulpt0=0A=0Aso that any user can write to the printer device fil=
e.=0A=0AI only fiddled a couple of other small things in order to make this=
 all work.=0AFirstly, I created my own versions of /usr/local/libexec/psif-=
text and also=0A/usr/local/libexec/psif-ps.=A0 Here they are:=0A=0A/usr/loc=
al/libexec/psif-text:=0A=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A#! /bin/sh=0A=0A/usr/local/bin/textps -c 1=
0 -l 60 -m 38 -t 46 && printf "\004" && exit 0=0A=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=0A/usr/local/l=
ibexec/psif-ps:=0A=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=0A#! /bin/sh=0A=0A/bin/cat && printf "\004" && exi=
t 0=0A=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=0A=0AThe parameters for textps that I have in my psif-text fil=
e were just some=0Aparameters that I slapped together after running a few t=
ests to see what=0Avalues created output that looked good to me.=A0 Your mi=
lage may vary.=0A=0AAfter I set up all of the above stuff, I noticed that m=
y attempts to use the=0A"lpr" command to print things from non-root user ac=
counts was still resulting=0Ain very long delays before anything would prin=
t.=A0 It took me some head scratch-=0Aing but I finally found the problem.=
=A0 In a nutshell, the problems was that=0Aat one point while I was trying =
to get this all going, I did in fact install=0Athe CUPS package (and friend=
s).=A0 As I learned, when you do this you get the=0Afollowing _different_ v=
ersion of "lpr" installed in a place where normal user=0Aaccounts are likel=
y to see it in their $PATH first:=0A=0A=A0  /usr/local/bin/lpr=0A=0AYikes!=
=A0 So we've got /usr/bin/lpr _and_ /usr/local/bin/lpr.=A0 I'm sure that at=
=0Asome point, somebody thought that it was a good idea to have two radical=
ly=0Adifferent programs in two different directories and give them both the=
 same=0Aname.=A0 Maybe there actually is some good reason for that, but it =
wasn't=0Ahelping me any, so I just did:=0A=0A=A0  cd /usr/local/bin=0A=A0  =
mv lpr{,-}=0A=A0  ln -s /usr/bin/lpr ./lpr=0A=0AThat's all.=0A=0ANow I can =
print either Postscript or plain text files to my LaserJet, from=0Aboth roo=
t and non-root accounts, and the printed output starts coming out=0Aof the =
printer within just a second or two every time.=A0 No queueing, no=0Afoolin=
g around, just push that document out lickety-split.=0A=0AI'm sure that som=
eone will tell me now that there are a zillion reasons=0Awhy I should not h=
ave done any of this, and that I just don't understand=0Athis or that, or t=
he fine technical reasons why CUPS is a wonderful tool=0Aand why I should b=
e using it.=A0 But this works for me, and I saved a lot=0Aof time by NOT ha=
ving to learn all of the ins-and-outs of using CUPS or,=0Amore importantly,=
 configuring it.=A0 (I'm sure its a fine package, but I have=0Aother things=
 that I need to be studying right now.)=0A=0AThe only thing that worries me=
 about my rather ad-hoc way of setting up=0Aa "personal" printer (as descri=
be above) is that I sort of wonder what=0Awill happen if I ever try to prin=
t something when something else is=0Acurrently printing.=A0 (I did somethin=
g similar to what I've described=0Aabove, but still rather different, back =
on my old 7.0-RELEASE system,=0Aand I think that there, if the printer was =
already busy and I went to=0Aprint something else, then that second print a=
ttempt would just error=0Aout right away.=A0 Obviously, if you want to stac=
k up a whole set of=0Adocuments for printing and then go out for lunch whil=
e they all print,=0Amy cheap-man's approach to setiing up a printer, as des=
cribed here, will=0Afail to give you the advantages of a real spooling/queu=
eing system.=A0 But=0Agiven that I personally rarely need to do that, for m=
e it is pretty much=0Aof a non-issue.)=0A=0AThat's all folks.=A0 I hope thi=
s all may be of some help to somebody.=0A=0A(Does anybody think that maybe =
this should go in the Handbook?)=0A=0A=0ARegards,=0Arfg=0A=0A=0AP.S.=A0 Whi=
le trying to debug my "slow printing" problem (see above) I did=0Asome goog=
ling around and found at least a few other people asking about=0Athis same =
sort of problem.=A0 One of them even mentioned that, like me,=0Awhen he inv=
oked "lpr" as root, the document gets printed immediately,=0Abut then tryin=
g to do that same thing under any ordinary user account=0Aresults in this b=
ig delay before the printer prints anything.=0A=0AObviously, that guy also =
got bit in the posterior by the /usr/local/bin/lpr=0Aversus /usr/bin/lpr is=
sue/problem.=A0 And I don't blame him for being puzzled,=0Aas I was.=A0 You=
 don't typically get radically different outcomes... where the=0Amain appar=
ent difference is the _speed_ of the command... when you run=0Acommand `X' =
as root and then as non-root.=A0 And that is only happening in this=0Acase =
because we've got two totally different programs with the same name,=0Awher=
e one is in your default path if you are root, and a different one is=0Ain =
your default path when you are non-root.=0A=0AI'm not persuaded that giving=
 these both the same name was really all that=0Agood a choice, from a user-=
interace/human-factors perspective.=A0 But I suppose=0Athat it is far too l=
ate to do anything about those choices now.=A0 Too much=0Aother stuff has p=
robably already been built assuming that things are this way.=0A=0A________=
_______________________________________=0Afreebsd-questions@freebsd.org mai=
ling list=0Ahttp://lists.freebsd.org/mailman/listinfo/freebsd-questions=0AT=
o unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"=
=0A=0A=0A=0AKudos for your persistence and for sharing this experience with=
 us. I too found CUPS a big waste of time for my uses. I have two networked=
 laser printers. One of them is an HP 4 (talk about your old workhorses) wi=
th a JetDirect card. That of course is self explanatory. But the other is a=
 Brother HL2040 laserjet which used to run on a parallel cable but I conver=
ted it over to USB about a year ago with the help of the nice folks in this=
 mailing list. This printer is driven by a FreeBSD-8.2-STABLE server using =
lpd and a relatively simple filter which envokes ghostscript to convert the=
 PS files it receives into the correct format. The driver is part of ghosts=
cript's library and it all works well. When I setup a M$ windows client I i=
nstall a simple PS printer (there are many of them available in a standard =
Windows machine). I do have to add Unix Printing Features on the M$ clients=
 and setup an lpr port but that again is built-in and you don't even need t=
he
 original OEM CD to do this. The print jobs come out quickly and in all the=
 years I've been using it I never have problems.=0A=0AI'm sure there are ma=
ny justifications for CUPS but so far I haven't needed it. 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1319712142.89939.YahooMailNeo>