mr_linux has asked for the wisdom of the Perl Monks concerning the following question:
HELP!my @ip_addrs = map /\(([^)]*)\)/, qx( /usr/sbin/traceroute $target);
#!/usr/bin/perl -w use CGI qw(:standard); print "Content-type: text/html\n\n"; $first = param("first"); $last = param("last"); &form_check; &validated; sub form_check { #Splits IP addresses (octets) on '.' @first = split(/\./,$first); @last = split(/\./,$last); #THIS IS WHERE $first AND $last ARE CHECKED TO SEE IF THEY ARE #IN PROPER FORM...I CUT THIS CODE OUT TO SHORTEN THIS POST } sub validated { #Calls trace for first IP (only used once) $run_once == 0; while($run_once == 0) { &trace; $run_once++; } #While 3rd octet of $first is less than or equal to 3rd octet of $last +, #and 4th octet of $first is less than or equal to 4th octet of $last while($first[2] <= $last[2] && $first[3] < $last[3]){ #While 4th octet of $first is less than 4th octet of $last while($first[3] < $last[3]){ $first[3]++; #Adds 1 to 4th octet, calls sub trace &trace; } #Is the 3rd octet of $first less than the 3rd of $last? #i.e, 192.168.0.1 and 192.168.1.254 while($first[2] < $last[2]) { $first[3] = 1; #Resets 4th octet to 1 $first[2]++; #Adds 1 to 3rd octet of $first } } } sub trace { print "<h1>Tracing route, one moment...</h1>"; #Rejoin octets into $target for tracerouting... $target = join('.', $first[0],$first[1],$first[2],$first[3]); #Run traceroute on $target, only capture IP address to array @ip_addrs my @ip_addrs = map /\(([^)]*)\)/, qx( /usr/sbin/traceroute $target); #Cycle through @ip_addrs, print compy.gif for each hop foreach $element (@ip_addrs) { print "<center><img src=\"compy.gif\"><\/a><br>$element<br><br><\/cent +er>"; $|++; } #Re-splits $target for octet analysis @first = split(/\./,$target); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Network topology mapping
by Zaxo (Archbishop) on Aug 30, 2001 at 11:47 UTC | |
by Masem (Monsignor) on Aug 30, 2001 at 15:29 UTC | |
by mr_linux (Novice) on Aug 30, 2001 at 20:54 UTC | |
by mr_linux (Novice) on Aug 31, 2001 at 23:30 UTC |