[comp.protocols.appletalk] A useful perl program - format atlook output

matthew@ooc.uva.nl (Matthew Lewis) (02/20/91)

Hello!  After a long period of fustration with the somewhat chaotic output
of atlook, last night I hacked together a perl program to print it somewhat
more understandably.  It is not elegant perl, and it could be made more
obviously portable (i.e., the directory is hard-coded), but it is useful.
If anyone cleans it up and makes it more elegant, I would love to see the
result.  I call it 'atprint' and it takes one parameter (optional), the
zone name.  If there are spaces in the name, you should enclose the name in
double quotes.

I hope that you find it useful.

Matthew Lewis
Sysadmin, CICT/OOC
University of Amsterdam

------>->-> Cut Here <-<-<----------
#!/usr/local/bin/perl
open(PIPE,"/usr/local/bin/cap60/atlook '$ARGV[0]' |") || die "Cannot open atlook";
$a = <PIPE>; $a = <PIPE>;
while (<PIPE>) {
	$index = substr($_,0,3);
	$name = substr($_,5,41);
	$name =~ s/\s*$//;
	$net = substr($_,53,4);
	$node = substr($_,63,3);
	$socket = substr($_,71,3);
	$list{"$node"} .= "$name\034";
}
print "\n\nNode list for network $ARGV[0]:\n";
print "Node	Names\n----	------------------------\n\n";
while (($key, $value) = each %list) {
	print "$key:";
	@names = split(/\034/,$value);
	@names = sort @names;
	for ($i=0; $i <= $#names; $i++) {
		print "	$names[$i]\n";
	}
	print "--------------------------------------------\n";
}
-- 
Matthew Lewis, University of Amsterdam		Grote Bickersstraat 72
+31-20-52 51 220				1013 KS  Amsterdam
Internet: matthew@ooc.uva.nl			The Netherlands
UUCP:	  uunet!mcsun!hp4nl!uvabick!matthew