#!/bin/sh 
#! perl 
eval 'exec perl -x $0 ${1+"$@"}'
        if 0;

#
# Graham Phillips 
# Los Angeles, June 1999.
#
# Determines a path of ASs (autonomous systems) for a given 
# traceroute output. It works by using the 'whois' program on the
# machine 'radb.ra.net'.  For example, try the following: 
# traceroute www.uct.ac.za | traceAS 
#
# An example output might look like the following (excluding the 
# leading '# '):
# 1 128.9.160.161 AS226
# 2 128.9.160.7 AS226
# 3 128.9.32.5 AS226
# 4 * *
# 5 4.24.40.13 AS1
# 6 4.24.4.17 AS1
# 7 4.24.4.22 AS1
# 8 4.0.1.17 AS1
# 9 4.0.1.1 AS1
# 10 4.0.5.65 AS1
# 11 4.0.6.45 AS1
# 12 137.39.250.245 AS701
# 13 146.188.148.98 AS702
# 14 146.188.147.122 AS702
# 15 146.188.136.221 AS702
# 16 146.188.161.169 AS702
# 17 146.188.160.57 AS702
# 18 157.130.34.190 AS701
# 19 196.30.121.33 AS2905
# 20 * *
# 21 * *
# 22 196.31.0.65 AS2905
# 23 * *
# 24 137.158.200.1 AS2905
# 25 137.158.128.7 AS2905
# -------end-------------
# 
# The * means that traceroute cannot determine the router
# at the particular hop distance.
#


while () {
	# strip whitespace
	s/\s*(.*)/\1/;
	@fields = split(/  /);
	$hop = $fields[0];
	$current_as = "*";
	$current_ip = "*"; 
	$_ = $fields[1];
	@fields = split(/ /);
	$name = @fields[0];
	$_ = @fields[1];
	if (s/\((\S+)\)/\1/) {
		# we know the IP address 
		$current_ip = $_; 
		open (INPUT1, "whois -h radb.ra.net $_ |");
		while () {
			if (/origin:/) {
				s/\S+\s+(\S+)/\1/;
				chop;
				$current_as = $_;
			} 
		}
	} 
	print "$hop $current_ip $current_as\n";
	close INPUT1;
}

    Source: geocities.com/grahamgrebe/contrib

               ( geocities.com/grahamgrebe)