anoopgulati has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use strict; # important pragma use warnings; # another important pragma my @hostname; @hostname = @ARGV; use Win32::ODBC; use Net::Ping; my $db = new Win32::ODBC("DSN=anoop2") || die "error connecting" ; Win32::ODBC::Error(); my @localtime= localtime (time); #CONVERT THE TIMESTAMP INTO THE #FOLLOWINGFORMAT SSMMHHMMDDYYYYPARSE THE DATA INTO #LOCALTIME ARRAY. ADD 1TO THE MONTH AS COUNT #STARTS FROM ZERO my $timenow = ($localtime[4] + 1)."/".($localtime[3])."/".($localtime[ +5]+1900)." ".$localtime[2].":".$localtime[1].":".$localtime[0]; my $p = Net::Ping->new("icmp"); $p->bind("127.0.0.1"); # Specify source interface of pings if ($p->ping(@hostname,3)) { $db->sql("insert into chk(device,pngtm,status) values('@hostname','$ +timenow','yes') ;"); $db->sql(" commit ;"); } else { $db->sql("insert into chk(device,pngtm,status) values('@hostname','$ +timenow','No') ;"); $db->sql(" commit ;"); };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: icmp socket error
by sasikumar (Monk) on Feb 07, 2005 at 11:09 UTC | |
by tye (Sage) on Feb 08, 2005 at 03:48 UTC | |
by anoopgulati (Initiate) on Feb 09, 2005 at 06:57 UTC | |
|
Re: icmp socket error
by sasikumar (Monk) on Feb 09, 2005 at 15:11 UTC | |
by Anonymous Monk on Feb 10, 2005 at 07:15 UTC | |
by greygeek (Initiate) on Feb 18, 2005 at 20:56 UTC |