use bio for ndb/query's output. this is a significant help with only 20ms
lag between terminal and cpu; makes a very large difference even at 3ms
for intensive scripted queries. e.g. (sorry, this is my version of rc that
has "break". i'm also assuming a class C network. you get the point.)
#!/usr/quanstro/bin/386/rc
rfork e
net = `{ndb/query ipnet $site ip |sed s:\.0::g}
aflag = 0
vflag = 0
for(i)
switch($1){
case -a
aflag = 1;
shift;
case -v
aflag = 1;
vflag = 1;
shift
case *
echo 'usage: freeip [-a] [-v]'>[1=2]
exit usage
}
for(i in `{seq 1 253}){
r = `{ndb/query ip $net^.$i ip}
q = `{ndb/query 10gip $net^.$i 10gip}
# it's illegal to have a duplicate ip and 10gip, unless
# the host is the same.
all=($r $q)
if(! ~ $#all 0 1){
a = `{ndb/query ip $net^.$i sys}
b = `{ndb/query 10gip $net^.$i sys}
if(! ~ $#a 1 && ! ~ $"a $"b){
echo error $net^.$i >[1=2]
echo ' ' ip ' ' $a>[1=2]
echo ' ' 10gip ' ' $b>[1=2]
}
}
if(~ $vflag 0)
if(! ~ $r ?* && ! ~ $q ?*){
echo $net^.$i
if (~ $aflag 0)
break
}
}
|