[comp.lang.perl] uucp map browser?

richard@pegasus.com (Richard Foulk) (11/04/90)

Before someone goes and reinvents another wheel...  does anyone have
any perl scripts for searching or browsing the Uucp maps?


-- 
Richard Foulk		richard@pegasus.com

bll@seer.UUCP (Brad Lanam) (11/04/90)

In article <1990Nov3.162853.19637@pegasus.com>
    richard@pegasus.com (Richard Foulk) writes:
>Before someone goes and reinvents another wheel...  does anyone have
>any perl scripts for searching or browsing the Uucp maps?

    Yes, I've got one -- does the unbatching, tools for creating the paths
file, and the "uuhosts" command.  Unfortunately, the "uuhosts" broke under
PL36/37.  I sent the piece that broke in to Larry.

    Let me know if you want it.

-- Brad
-- 
Until the next disk seek...
   -- Brad Lanam    ...!uunet!{seeker|unisoft}!seer!bll    bll@seer.uucp

urlichs@smurf.sub.org (Matthias Urlichs) (11/04/90)

In comp.lang.perl, article <1990Nov3.162853.19637@pegasus.com>,
  richard@pegasus.com (Richard Foulk) writes:
< Before someone goes and reinvents another wheel...  does anyone have
< any perl scripts for searching or browsing the Uucp maps?
< 
I have written a fairly large & complex script to analyze the maps (piping
them thru pathalias in the process), domainizing entries if possible, and
splitting out the entries to different tables (i.e., all .uucp entries go to
one file, all .ka.sub.org (my "home domain") to another).

You can also tell it to remember which map a given entry came from.

It's 20k big; I'll mail it to anyone who is really interested.
(Beware: almost no documentation.)

-- 
Matthias Urlichs -- urlichs@smurf.sub.org -- urlichs@smurf.ira.uka.de     /(o\
Humboldtstrasse 7 - 7500 Karlsruhe 1 - FRG -- +49+721+621127(0700-2330)   \o)/

cander@unisoft.UUCP (Charles Anderson) (11/06/90)

From article <1990Nov3.162853.19637@pegasus.com>, by richard@pegasus.com (Richard Foulk):
> Before someone goes and reinvents another wheel...  does anyone have
> any perl scripts for searching or browsing the Uucp maps?
> Richard Foulk		richard@pegasus.com

Below is my entry.  It relies on a pre-compiled database (built by
grep) that really should be a DBM file, but when I wrote this, DBM
files and assoc arrays seemed to have problems.  Someday I'll finish it.

---cut here---
#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 1 (of 1)."
# Contents:  descsite
# Wrapped by cander@lolita on Mon Nov  5 17:06:46 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'descsite' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'descsite'\"
else
echo shar: Extracting \"'descsite'\" \(1271 characters\)
sed "s/^X//" >'descsite' <<'END_OF_FILE'
X#!/usr/local/bin/perl
X#
X# Synopsis: descsite [-i] sitename
X#           prints out the map entry for a uucp site
X#           -i causes the site database to be initialized.
X#
X# Author:   Charles Anderson   (cander@unisoft.com)
X#
X
X$USAGE="Usage: descsite [-i] sitename";
X$MAPDIR="/usr/spool/maps/comp.mail.maps";
X$SITENAMES="site_names";
chdir $MAPDIR || die "Cannot chdir to mapdir: $MAPDIR";
X
if ($ARGV[0] eq "-i") {
X    print "Initializing site database.  Please wait...\n";
X    system("grep ^#N [du]*. > $SITENAMES");
X    print "Done\n";
X    exit 0 if ($#ARGV == 0);
X    shift;
X}
X
if ($#ARGV != 0) {
X    print "$USAGE \n";
X    exit 1;
X}
X$site=$ARGV[0];
X
open (IN, $SITENAMES) || die "Cannot open $SITENAMES\n";
while (<IN>) {
X    if (/^(\S+):#N\s+$site[\s,\$]/o) {
X	$FILE=$1;
X	last;
X    }
X}
close(IN);
X
die "Unable to locate site $site in file site name database\n" 
X    unless defined($FILE);
X
print "Map information for $site in $MAPDIR/$FILE\n";
X
open (MAP, $FILE) || die "Cannot open $FILE";
X
while (<MAP>) {
X    last if /^#N\s+$site[,\s\$]/o;
X}
X
die "Unable to locate map info for site $site in file $FILE\n" if eof(MAP);
X
X$pager = $ENV{'PAGER'} || 'more';
X
open(OUT, "| $pager");
print OUT $_;
X
while (<MAP>) {
X    last if /^#N/o;
X    print OUT $_;
X}
X
close(OUT);
END_OF_FILE
if test 1271 -ne `wc -c <'descsite'`; then
    echo shar: \"'descsite'\" unpacked with wrong size!
fi
chmod +x 'descsite'
# end of 'descsite'
fi
echo shar: End of archive 1 \(of 1\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have the archive.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
-- 

Unix is the Winchester Mystery   |  Charles Anderson, UniSoft Corp.
House of software design.        |  {sun, ucbvax, uunet}!unisoft!cander

chip@tct.uucp (Chip Salzenberg) (11/07/90)

For those of you who already have Smail 3, check out the "uuwho"
utility.  It's written in C, but it works well anyway.  :-)
-- 
Chip Salzenberg at Teltronics/TCT     <chip@tct.uucp>, <uunet!pdn!tct!chip>
    "I've been cranky ever since my comp.unix.wizards was removed
         by that evil Chip Salzenberg."   -- John F. Haugh II