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 } } Notes: Wed Mar 19 15:07:58 EDT 2008 geoff Please (re)read style(6) and edit your code to conform, then resubmit this patch. Thanks. Reference: /n/sources/patch/sorry/ndbqrybio Date: Wed Mar 12 20:36:31 CET 2008 Signed-off-by: quanstro@quanstro.net Reviewed-by: geoff --- /sys/src/cmd/ndb/query.c Wed Mar 12 20:32:41 2008 +++ /sys/src/cmd/ndb/query.c Wed Mar 12 20:32:40 2008 @@ -7,6 +7,7 @@ #include static int all, multiple; +Biobuf bout; void usage(void) @@ -22,7 +23,7 @@ { for(; nt; nt = nt->entry) if (strcmp(nt->attr, rattr) == 0) - print("%s\n", nt->val); + Bprint(&bout, "%s\n", nt->val); } void @@ -38,7 +39,7 @@ if (multiple) prmatch(t, rattr); else if(p) - print("%s\n", p); + Bprint(&bout, "%s\n", p); ndbfree(t); free(p); return; @@ -57,8 +58,8 @@ /* all entries */ for(t = ndbsearch(db, &s, attr, val); t; t = ndbsnext(&s, attr, val)){ for(nt = t; nt; nt = nt->entry) - print("%s=%s ", nt->attr, nt->val); - print("\n"); + Bprint(&bout, "%s=%s ", nt->attr, nt->val); + Bprint(&bout, "\n"); ndbfree(t); } } @@ -69,7 +70,7 @@ int reps = 1; char *rattr = nil, *dbfile = nil; Ndb *db; - + ARGBEGIN{ case 'a': all++; @@ -78,7 +79,7 @@ multiple++; break; case 'f': - dbfile = ARGF(); + dbfile = EARGF(usage()); break; default: usage(); @@ -97,7 +98,9 @@ default: usage(); } - + + if(Binit(&bout, 1, OWRITE) == -1) + sysfatal("Binit: %r"); db = ndbopen(dbfile); if(db == nil){ fprint(2, "%s: no db files\n", argv0);