darylm@illian.UUCP (Daryl V. McDaniel) (04/20/88)
Hello, I am presenting two shell scripts which I use to provide functionality similar to the Berkeley finger(1) command, but for USENET hosts instead of local users. These scripts assume that the maps published in Comp.mail.maps have been extracted and are all on-line in a common directory. The script, mkuufdb, will read the map files and produce a single sorted database, indexed by domain name or host name, containing the information one considers important. The next script, uuf, performs a binary search of the database generated by mkuufdb and reports on all sites whose domain or host names begin with the strings provided as arguments to uuf. On our system mkuufdb generates a database that is 555,323 bytes long and the maps take up 1,900,560 bytes. The uuf script has been able to locate and print the first system in an average of 1 second. Currently systems that are only listed as gateways to domains in the d.* maps will not be found by uuf. For example, the system "tektronix" is only listed in d.usa.or.1 as the gateway to .tek.com. The script will complain that "tektronix" is not a registered USENET site but will find ".tek" and list "tektronix" as its gateway. A possible problem you may encounter is that not all map entries are of the form: #[NOCEP]\tRest of line If there are spaces between the "#N" and the rest of the line the machine will not be included in the database. If there are spaces between one of the other identifier characters and the rest of the line then that field will be blank. Unfortunately there are between 20 and 30 entries in the maps which fall into this category. Luckily they follow enough of a pattern that fixing them can be mostly automated. The patterns, in order of frequency, are: six spaces two spaces two tabs one space more than six spaces Since I don't have access to any XENIX or Sys V machines I don't know how portable the scripts are. I hope that you find uuf as useful as I do. PS The shell scripts follow my signature block. They are not SHAR archives so they need to be extracted manually. I was not able to get them to extract properly when packaged with the version of shar that I have. -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_- Daryl V. McDaniel Micronetics USENET: ...tektronix!nosun!illian!darylm 4730 S.W. 182nd Ave. TELEX: WUI 6972206 Aloha, OR 97007 PHONE: (503) 224-7056 -------------------- CUT HERE -------------------- CUT HERE ----------------- #!/bin/sh # mkuufdb.sh # Make UUF (uucp host finger) database # # Reads the d.* and u.* files in MAPDIR and produces a file, UUFDB, in # DBDIR which is used by the companion shell script uuf to provide a # function similar to finger(1) for registered USENET hosts. MAPDIR=/usr/lib/uucp/maps DBDIR=/usr/lib/uucp/maps cd $MAPDIR cat d.* u.* | awk ' BEGIN { FS = "\t"; host = "" } /^#N/ { if (host == "") host = $2 else { printf("%s\t%s\t%s\t%s\t%s\n",host,org,contact,email,post) host = $2 org = "" contact = "" email = "" post = "" } } /^#O/ { org = $2 } /^#C/ { contact = $2 } /^#E/ { email = $2 } /^#P/ { post = $2 } END { printf("%s\t%s\t%s\t%s\t%s\n",host,org,contact,email,post) } ' | sort +0 -1 > ${DBDIR}/UUFDB -------------------- CUT HERE -------------------- CUT HERE ----------------- #!/bin/sh # uuf.sh # Provides a function similar to finger(1) for machines registered in the # uucp maps. # # Assumes that the d.* and u.* entries and the uuf database, UUFDB, are in # the directories MAPDIR and DBDIR, respectively. MAPDIR=/usr/lib/uucp/maps DBDIR=/usr/lib/uucp/maps echo "" if test $# -lt 1 then echo "\007usage: uuf machine-name [machine-name]...\007\n" exit 1 fi narg=$# for mach in $* do look $mach ${DBDIR}/UUFDB > /tmp/uuf$$ if test $? -ne 0 then echo "The machine named $1 does not appear to be a registered USENET site.\n" rm -f /tmp/uuf$$ else awk ' BEGIN { FS="\t" } /^[A-Za-z\.]/ { if ( substr($1,1,1) != "." ) printf("HOST: %s\n",$1) else { idx = index($1,",") if (idx == 0) { domn = $1 gate = "" }else{ domn = substr($1,1,idx-1) gate = substr($1,idx+2) } printf("DOMAIN: %s\n",domn) if ( gate != "") printf("GATEWAY: %s\n",gate) } printf("COMPANY: %s\n",$2) printf("ADDRESS: %s\n",$5) printf("CONTACT: %s\n",$3) printf("E-MAIL: %s\n",$4) printf("\n") }' < /tmp/uuf$$ | more rm -f /tmp/uuf$$ narg=`expr $narg - 1` if test $narg -ne 0 then echo "\n-- End of listings for $mach. Press <RETURN> to continue. --\c" read junk echo "-----------------------------------------------------------------\n" fi fi done # ------ END