Hi All - chasing down a means to initiate a traceroute, record results, and extract IP addresses in an (array?)
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 -
-
#!/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]
-
-
Regards,
Hutch
2 2329 eWish 971
Recognized Expert Contributor
I have not had the need to do any trace route stuff. Have you looked into using Net::Traceroute might make it easier.
The next line of code won't return anything useful, since you are declaring it in your if statement block. Therefore, it goes out of scope when you try to access it again. Use strict will catch this for you. - my $trace = `tracert $IP 2>&1`;
This next line does not do anything either.
If you want to check for the $ip variable for at least six alpha numeric characters then you will need something like this.
--Kevin
Thanks for the Response Kevin,
The Unix Sys Admin showed me the error of my ways. I thought I couldn't run traceroute from the command line because of a permissions issue, when in fact it just needed to be called differently.
EG, instead of typing: traceroute 72.14.207.99
I needed to type: /usr/sbin/traceroute 72.14.207.99
With that being said, was able to design a script to do what I wanted:
Here it is if anyone is interested: -
-
#!/usr/bin/perl -w
-
use strict;
-
use warnings;
-
-
use CGI qw(:standard);
-
-
my $CIP = param('csrip');
-
-
my $trace;
-
my $firstIP;
-
my $eachHOP;
-
-
# only proceed if an IP address is entered via form
-
if ($CIP =~ /\d.{1,3}\.\d.{1,3}\.\d.{1,3}\.\d.{1,3}/) {
-
-
# execute traceroute based on IP, do not perform DNS lookup
-
# and send the first line of the response to the bit-bucket
-
$trace = open(TRACE, "/usr/sbin/traceroute -n $CIP 2>/dev/null |");
-
}
-
-
# if no IP address entered via form then die and do not proceed
-
else {
-
-
die;
-
}
-
-
# loop through the system output
-
while ($firstIP = <TRACE>) {
-
-
# only take the first IP address on a line
-
$firstIP =~ /\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+/;
-
-
$eachHOP = $1;
-
-
# prints each IP address on the hop path
-
print "$eachHOP\n";
-
}
-
-
close TRACE;
-
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Stephen Briley |
last post by:
Hi all,
I would like to write a python script that takes input
of 2 ip address, one a start address and the other the
end address and prints a list of all ip address in
between in dotted-decimal format. If so, what is the
recommended way? Is there a way to do this with the
supplied python modules?
Thanks!
|
by: newbiecpp |
last post by:
I have hard time to understand run-time environment. Let assume that I have
a program that has a simple variable alpha. When this variable is
statically allocated, the compiler can use the absolute address of alpha to
access to it. What confuses me is that when the variable is dynamically
allocated, how does the compiler implement it? We...
|
by: john |
last post by:
I would like to develope a system using a web or non-web based client
(FrontPage, Access, etc.) that can send requests to various travel web
site (using our user name and password for each) and extract the
requested pricing and information and compile it together for
comparison. Can anyone suggest the best way to do this? I assumed XML
would...
|
by: Heiko Besemann |
last post by:
Dear group,
I created an aspx page using System.Diagnostics.Process() to launch
"tracert" from shell and redirect output to Response.Output which
prints it as text/plain into my browsers window. Now that works fine
so far. My problem is that while tracert process is running and ASP
..NET is putting data into the pages output stream, my...
|
by: Mam |
last post by:
Hi
I had developed one site,that site hides all the email
addresses.Now i want to develope an application whose
extract mail addresses from that site,Is there any
solution to this.If u know how to extract or any related
websites let me know.Because i have tried in so many ways
but i didn't get the solution.
Thanks in advance
| |
by: Mike Cox |
last post by:
Andy M wrote:
> ALERT
>
> There is a person by the name of Mike Cox who's trying
> to turn this mailing list into a Big-8 newsgroup.
No, I'm trying to get teh postgresql groups which are already ON usenet to
follow proper usenet guidelines. In order to be under the comp.* hierarchy
the server MUST go through RFD and CFV. Otherwise it...
|
by: tthomas |
last post by:
Greetings,
I am using CDO.Message to send email messages from my application. I now
need to send email to existing distribution lists in our Global Address List.
However, our exchange server blocks sending to distribution list (i.e.
distribution list is named MyDistList and its email address is
MyDistList@mycompany.com) from SMTP email.
...
|
by: hillside |
last post by:
I have hundreds of macros that use the SendObject action to email reports to several recipients. I need to compile a list of all recipients for each report. There are around 400 .mdb files with a total of around 4000 reports. Is there a way to programmatically extract the email addresses of the recipients from the macros?
|
by: Dennis |
last post by:
Hi, I have a text file that contents a list of email addresses like
this:
"foo@yahoo.com"
"tom@hotmail.com"
"jerry@gmail.com"
"tommy@apple.com"
I like to
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |