#/usr/bin/perl -w # traceroute.pl: Emulates /usr/sbin/traceroute via ping. # ($osname, $hostname, $osversion) = split (/ /, `uname -a`); $PINGPATH = "/usr/sbin/ping"; # $PINGPATH = "/bin/ping"; $PINGOPT = "-t"; $PINGEXIT = "Time exceeded in transit"; $PINGDONE = "is alive"; $MAXREAD = 10; $MAXHOPS = 25; $KNOWNOS = "sunos"; $KNOWNVER= "5.6"; # show usage unless we have a host to ping to die "usage: pmtracerout host\n" unless $ARGV[0]; # some simple error checking die <) { # print ":>$line"; last if $line =~ /$PINGEXIT/; if ($line =~ /$PINGDONE/) { print "$wait. $line"; exit; } $i++; die <= $MAXREAD; Error: Could not find timeout string in first $MAXREAD lines of ping output. Exiting... STRINGNOTFOUND } sleep 2; close (PING); if ($line =~ /from (.*)$/) { print "$wait. $1\n"; } else { # seems we didn't find anything in the ping output. warn "Error: Could not find timeout string in ping output\n"; } }