perlquestion
as :)
Hi,
In the following code I am using the Win32::PingICMP module to ping IP Addresses and print the roundtrip times. However, when I run the code I get the following error:
Can't locate loadable object for module Win32::API in @INC <@INC contains: c:/Perl/lib/ c:/Perl/site/lib/.> at c:/Perl/site/lib/Win32/PingICMP.pm line 16. BEGIN failed -- compilation aborted at c:/Perl/site/lib/Win32/PingICMP.pm line 16.
I have saved all the appropriate modules in the right directories as well.
I would greatly appreciate it if someone could help me out here.
Thanks.
A.
<CODE>
#!/usr/local/bin/perl
use strict;
use Win32::ODBC; # Enables ODBC database connectivity
use Win32::PingICMP;
my $dsn = "postdev";
my $user = "archnas";
my $password = "something";
# Get all process related data from the database
# Declare Variables
my $rc;
my $sql;
my @ip;
# Open ODBC session to database
my($odbc_session) = new Win32::ODBC("dsn=$dsn; uid=$user; pwd=$password;") or die "Error connecting to $dsn\n";
# SQL
$sql = "
select DWH_LAN_IP
FROM
DAPO_CPCT_MGMT.DWH_Ntwk_Adr
WHERE DWH_Ping_Flg = 'Y'
";
# Submit SQL
$rc = $odbc_session->Sql("$sql");
# Check for SQL errors
if(defined $rc)
{
my $sql_error = $odbc_session->Error;
my @sql_error = split /([-\[\]"])/,$sql_error;
print "$sql\n";
print "SQL error: @sql_error[4,-2]\n";
exit;
}
# Retrieve answerset
while($odbc_session->FetchRow())
{
# Stores each IP Address in the @ip.
my $ip_add = $odbc_session->Data();
#print "$ip_add\n";
push @ip, $ip_add; # Pushes each IP Address in the @ip to the top.
}
print map {"$_\n"} @ip;
my $p = Win32::PingICMP->new();
foreach (@ip) {my $ping = $p->ping($_, 5);
if ($ping == 1){
$rtime = $p->details->{roundtriptime};
}
else {$rtime = 0;}
print "ping of $_ took $rtime ms\n";
}
$p->close();
</CODE>