perl script to traceroute an IP from windows


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting perl script to traceroute an IP from windows
# 1  
Old 08-29-2012
perl script to traceroute an IP from windows

I am writing a perl code(windows) to traceroute IP address and to print the output.
I had executed the below code which was taken from cpan modules

Code:
#!C:/perl/bin/perl.exe
use Net::Traceroute;
$tr = Net::Traceroute->new(host=> "google.com");
if($tr->found) {
my $hops = $tr->hops;
if($hops > 1) {
print "Router was " .
$tr->hop_query_host($tr->hops - 1, 0) . "\n";
}
}


But it is generating the below error message

C:\scripts>perl traceroute1.pl
No output from traceroute. Exec failure? at C:/Perl/site/lib/Net/Traceroute.pm
line 359.


Could anyone please help me in sorting this issue or provide me the alternative script?
# 2  
Old 09-07-2012
Could anyone please help me in sorting this issue or provide me the alternative script?
# 3  
Old 09-07-2012
I haven't used Net::Traceroute on windows, however the traceroute executable on windows is called tracert. You can specify the trace_program in the constructor so that the declaration of $tr becomes
Code:
my $tr=Net::Traceroute->new(
                            host=> "google.com"
                            trace_program=>"tracert"
                           );

;

Note that you can also set debug=>1 in the event that you still need to see what is going wrong.
This User Gave Thanks to Skrynesaver For This Post:
# 4  
Old 09-11-2012
Thanks boss....

But I haven't understood the below line.
Is that any external program(.exe) or any other ?

trace_program=>"tracert"
Could you please explain with the code ?

Thanks once again for your reply ...
# 5  
Old 09-12-2012
Net::Traceroute uses the traceroute program to obtain the jump information.

On Windows that program is called tracert rather than traceroute (the name of the executable on linux systems), in order to a use the windows binary you need to set the trace_program setting when you call the Net::Traceroute constructor, so adding the additional parameter trace-program=>"tracert" sets that value for the instance you create. Note that the code I originally provided will actually throw an error it should read:

Code:
my $tr=Net::Traceroute->new(
                             host          => "google.com",                             
                             trace_program => "tracert"                            
);

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl script to parse multiple windows event logs.

Hi all, I am developing a log parsing agent in perl to send windows Event logs to Zenoss Monitoring tool. Using Win32::EventLog i can able to get the Event messages but only one Eventype eg Application or System could able to parse at a time. Can you please help to how to open mutiple eventlogs... (3 Replies)
Discussion started by: kar_333
3 Replies

2. IP Networking

Perl : traceroute error

I am writing a perl code(windows) to traceroute IP address and to print the output. Could anyone please supply the code. I had executed the below code which was taken from cpan modules #!C:/perl/bin/perl.exe use Net::Traceroute; $tr = Net::Traceroute->new(host=> "google.com");... (1 Reply)
Discussion started by: giridhar276
1 Replies

3. Programming

Problem with Perl script after moving from a Windows/Apache Server to a UNIX server.

I have a Perl script that worked fine before moving it to justhost.com. It was on a Windows/Apache server. Just host is using UNIX. Other Perl scripts on other sites that were also moved work fine so I know Perl is functioning. The script is called cwrmail.pl and is located in my cgi-bin. When I... (9 Replies)
Discussion started by: BigBobbyB
9 Replies

4. Shell Programming and Scripting

Launch a windows program from perl script

Hi i wanted to know if any one can give me an example on how to launch a windows program in a perl script. I wanted to open the nmap software on my computer with a perl script, i heard this can be done with the system function. Would the function be in this format: $text =... (1 Reply)
Discussion started by: kingbp
1 Replies

5. Shell Programming and Scripting

Traceroute script weird output

This script is giving weird output #!/bin/bash NETPATH=(`/bin/traceroute -n 4.2.2.2 | awk '{print $2}'`) for i in "${NETPATH}" do echo $i done The output: to 11.11.11.1 1.1.1.1 99.111.208.2 traceroute_test.sh traceroute_test.sh (7 Replies)
Discussion started by: thumbs
7 Replies

6. Windows & DOS: Issues & Discussions

Running perl script from a VB.NET windows service

Here is the snippet of the code that I'm trying to execute. Stat of the service does not launch perl script. OnStop works fine. Please could you help here. Public Class Service1 Protected Overrides Sub OnStart(ByVal args() As String) ' Add code here to start your service. This... (0 Replies)
Discussion started by: hansini
0 Replies

7. UNIX for Dummies Questions & Answers

Need help configuring Active Perl on Windows Vista.: Perl Scripting on Windows

Hi All, Need help configuring Active Perl on Windows Vista. I am trying to install Active Perl on Windows Vista. The version of Active Perl i am trying to install is : ActivePerl 5.10.1 Build 1006 After installing it through cmd, When i try to run perl -v to check the version, i get the... (2 Replies)
Discussion started by: Vabiosis
2 Replies

8. Shell Programming and Scripting

Looking for a perl script (windows) to delete the contents of a file

Hi All, Im having a file named logserver.txt. I want a perl script to take a backup of that file, along with the datestamp; move the file to a different location or empty the contents of the file after backup. Remember, the file gets generated when the related service starts. My condition is... (14 Replies)
Discussion started by: ntgobinath
14 Replies

9. Shell Programming and Scripting

How to change a directory on windows via perl script

How to change a directory on windows via perl script. I wanna mount a share on windows via perl script. I have used:- system("dir"); gives the list of directories in the drive i am.This command works well. Now i want to move from c drive to z drive via perl script.I am using:- ... (2 Replies)
Discussion started by: TRUPTI
2 Replies

10. Shell Programming and Scripting

Merge two files in windows using perl script

Hi I want to merge two or more files using perl in windows only(Just like Paste command in Unix script) . How can i do this.Is ther any single command to do this? Thanks Kunal (1 Reply)
Discussion started by: kunal_dixit
1 Replies
Login or Register to Ask a Question