From: Geoff Collyer <geoff@collyer.net>
To: 9fans@collyer.net
Subject: [9fans] lp improvements
Date: Wed, 16 Apr 2003 20:07:46 -0700 [thread overview]
Message-ID: <168443d47fcd8dd22e9612ab9a18d540@collyer.net> (raw)
Since Plan 9 systems at a site typically share a file server, I've
modified lp to not send jobs (via port 515) to the machine responsible
for the printer, just to enqueue the job, but rather to just put the
job in the spooler queue and start the appropriate dæmon or kick the
responsible machine to start the dæmon. (It's still possible to
queue jobs on non-plan-9 systems using non-generic daemon or spooler
scripts in the devices file.)
I've made the last field ("FIFO") of /sys/lib/lp/devices optional. If
omitted, it now defaults to "generic". In /sys/lib/lp/spooler, smart
is my improved version of generic. You could copy or rename it to
generic, but I wanted to avoid at least that one replica conflict.
: cpu; cat /sys/lib/lp/devices
# device_name loc dest_host phys_dev_name speed class def_proc spooler stat kill daemon sched
foo home cpu.collyer.net foo.collyer.net - post+HPJCL+nohead+300dpi generic smart hp generic hp
; history -D lp
Apr 12 21:23:25 PDT 2003 lp 5454 [geoff]
lp:137,138 d /n/dump/2003/0412/rc/bin/lp:136
<
< # parse devices
lp:155,159 d /n/dump/2003/0412/rc/bin/lp:152
<
< # supply defaults
< if (~ $#SCHED 0 || ~ $SCHED '')
< SCHED=generic # was FIFO
<
# To unbundle, cd to /sys/lib/lp and run the rest of this file
echo sched/generic
sed 's/^X//' >sched/generic <<'!'
X#!/bin/rc
ls -ptr $* | sed -n -e '/^[^.].*\.[0-9][0-9]*\.[1-9][0-9]*$/p'
!
echo spooler/smart
sed 's/^X//' >spooler/smart <<'!'
X#!/bin/rc
X# a smarter version of the `generic' spooler.
X# all our Plan 9 systems share a common file system, thus a common lp spool.
X# so stop this crazy business of sending jobs around via port 515;
X# just stick the job in the queue and kick the guy who runs the printer.
rfork en
if (! ~ $DEBUG '')
X flag x +
pfx=`{echo $LPMACHID | sed 's/\..*//'}^.$pid
qdir=$LPSPOOL/$LPDEST
X{ mkdir $qdir && chmod 777 $qdir } >[2]/dev/null
X# Process and enqueue files to be printed. take arguments as input files.
i=0
if (~ $#* 0)
X * = /fd/0
for (f) {
X i = `{echo $i + 1 | hoc}
X # check access to the file so that you know that a failure in the
X # processing is a drastic error which will cause an exit from lp.
X if (! test -r $f)
X echo $f: not readable or missing >[1=2]
X if not {
X job=$pfx.$i
X @ {
X rfork n
X bind -b $LPLIB/process /bin
X $LPPROC
X } <$f >$qdir/.$job # temporary name
X if (~ $status '') @ {
X cd $qdir
X echo $LPMACHID $LPUSERID $job 0 >$job^id
X mv .$job $job # convert to real name
X }
X if not {
X rm -f $qdir/.$job
X exit 'preprocessing failed'
X }
X }
X}
X# kick remote daemon if needed; lp -R just runs the daemon
if (! ~ $THIS_HOST $DEST_HOST && ! ~ $DAEMON -)
X rx $DEST_HOST 'LPDEST='^$LPDEST^' lp -R'
X# lp will start the appropriate daemon (not lpdaemon) locally when we return
exit ''
!
reply other threads:[~2003-04-17 3:07 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=168443d47fcd8dd22e9612ab9a18d540@collyer.net \
--to=geoff@collyer.net \
--cc=9fans@collyer.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).