Discussion:
[9fans] lpsend.rc: Am I going crazy?!
(too old to reply)
l***@proxima.alt.za
2013-07-22 11:40:18 UTC
Permalink
in /sys/lib/lp/bin/lpsend.rc the following lines seem altogether wrong
to me:

6: if (~ $#dialstring 0 || ! ~ $dialstring '') {
7: dialstring=$1

and

15: if (! ~ $dialstring '')
16: exit 'lpsend: no dialstring'

I _must_ be missing something, but I can't see it!

++L
erik quanstrom
2013-07-22 14:42:58 UTC
Permalink
Post by l***@proxima.alt.za
in /sys/lib/lp/bin/lpsend.rc the following lines seem altogether wrong
6: if (~ $#dialstring 0 || ! ~ $dialstring '') {
7: dialstring=$1
certainly wierd.

i read this as trying to convert from sys→dom. if that does
not work, just use $1. otherwise use the resulting dom
returned from ndb/query.

for me, tcp!sysname!printer will work whenever
tcp!domname!printer will work. also hard-coding tcp is
incorrect. the connection server fixes that for you.
all this code seems to make things more fragile, and
less general.

i would think this code would make more sense.

#!/bin/rc
lpsend $1 || exit lpsend: $status

however, since lpsend.c doesn't call netmkaddr like one would
expect, i think you'll need to add change it to this

fn netmkaddr{
# lpsend is calls dial with incorrect arguments; should be
# dial(netmkaddr(dialstring, "tcp", "printer"), 0, 0, 0)
# please fix that, and remove this function.
defnet=tcp
defservice=printer

ifs='! ' {x=`{echo -n $1}}
switch($#x){
case 1
echo $defnet!$1!$defservice
case 2
# bad hueristics
if(~ $x(1) net || test -e /net/$x(1)/clone || ~ $x(1) */*)
echo $x(1)^!^$x(2)^!$defservice
if not
echo $defnet!$x(1)^!$x(2)
case *
echo $1
}
}
lpsend `{netmkaddr $1} || exit lpsend: $status

Loading...