Here's what I'm thinking about so far, wonder if anyone's been down this road before and can offer advice if I'm going the right direction or not.
untested - pending permissions to initiate traceroute from server
Expand|Select|Wrap|Line Numbers
- #!/usr/bin/perl -w
- use strict;
- use warnings;
- use CGI qw(:standard);
- # assign a variable name to the CGI form value of the IP address
- my $IP = param('csrip');
- # only proceed if the user inputs a value that exceeds 6 characters
- # as they may not know the IP address and we want to ignore if left blank
- if ($IP = .{6,}) {
- # do a system call to execute the traceroute command?
- # assign the stderr and stdout response to a variable
- my $trace = `tracert $IP 2>&1`;
- }
- # should I try to extract the IP addresses from the long string of stderr & stdout using a find/replace?
- # or something else?
- (my $iponly = $trace) =~ s/xxxxxxxxxx;
- # assuming the path of substitution is successful
- # convert the new $iponly variable to an array
- my @IPLIST= split(/,/,$iponly);
- # then extract the IPs as needed
- print "the path is $IPLIST[1], $IPLIST[2]
Hutch