Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

tracert equivalent 2

Status
Not open for further replies.

vcherubini

Programmer
May 29, 2000
527
US
Hello:

I am working on a Perl program that will idenify people who come to my site.

I am developing it on a Win32 machine, however, it will be used on a Linux server.

Is there a program in Linux (redhat 6.1) that is the same as the DOS tracert that takes an IP address and tells you what host it is from?

If so, what is it and how do you use it?

Thanks,
-Vic vic cherubini
krs-one@cnunited.com
 
"traceroute" is what you want, and it works pretty much the same. Enter "man traceroute" into the command prompt if you want more information.
 
Hi,

Yes just do '/sbin/traceroute or suchlike. One thing to note is that linux traceroute uses udp packets by default whereas M$ versions use icmp. Sometimes the udp packets may be firewalled but icmp let thru. If you want to use icmp traceroute on linux its '/sbin/traceroute -I .

However, for what you want to do its much easier to use the environment variables. The following is an example perl cgi script that prints them all out...

#!/usr/bin/perl
print "Content-type:text/html\n\n";
print <<EndOfHTML;
<html><head><title>Print Environment</title></head>
<body>
EndOfHTML
foreach $key (sort(keys %ENV)) {
print &quot;$key = $ENV{$key}<br>\n&quot;;
} print &quot;</body></html>&quot;;

[end]

What you'd want out of the above is probably just this :

print &quot;Remote IP addr =$ENV{'REMOTE_ADDR'}\n&quot;;

Rgds
 
Thanks guys. I know about environment variables, thats what I am using to track IP's of people visiting my site. I just want to pass them to traceroute to find out what city they are coming from.

Thanks for the help.
-Vic vic cherubini
krs-one@cnunited.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top