my $p = Net::Ping->new("icmp");
if ($p->ping($computer)) {
#run your checks
} else {
print"* Unable to Ping $computer *\n";
}
$p->close();
}
####
if ($key = $Registry->Connect("$computer","LMachine/Software/Network Associates/" .
"TVD/NetShield NT/CurrentVersion/" {Access=>KEY_READ} ) ) {
unless ($version = $key->GetValue("szProductVer")) {
$version = "Unknown";
}
unless ($dat = $key->GetValue("szVirDefVer")) {
$dat = "Unknown";
}
unless ($engine = $key->GetValue("szEngineVer")) {
$engine = "Unknown";
}
}
##
##
use Win32::TieRegistry( Delimiter=>"/" );
##
##
#
# GetCurrentVersion will the Mcafee download page and grab the version number
# for the latest DAT, superDAT, and engine.
sub GetCurrentVersion {
my $key;
my $dat;
my $superdat;
my $engine;
my $html_code;
my $row;
my $ts;
#
# Lets access the Network Associates download page for the Virus Info.
my $ua = new LWP::UserAgent;
my $url = 'http://www.mcafeeb2b.com/naicommon/download/dats/find.asp';
my $request = new HTTP::Request('GET',$url);
#
# Do we need to login?
#$request->authorization_basic('login', 'password');
$ua->timeout(10);
my $response = $ua->request($request);
my $responsecode = $response->code();
#
# Now we need to gather the information.
if ($responsecode != 200) {
print "Failed to Access the Mcafee site!: $responsecode\n";
} else {
#
# Load the HTML junk into a var.
my @array = (split "\n", $ua->request($request)->as_string);
foreach (@array) {
$html_code .= $_ . "\n";
}
}
#
# It's time to use TableExtract. We use the File Version and Date for
# header info to locate our tables. Once found; we look for certain
# names and assing the version info to our needed vars.
my $te = new HTML::TableExtract( headers => [qw(File Version Date)] );
$te->parse($html_code);
foreach $ts ($te->table_states) {
#print "Table found at ", join(',', $ts->coords), ":\n";
foreach $row ($ts->rows) {
#
# DAT Version
if (@$row[0] =~ /DAT File for weekly v4x \(DAT Only\)/) {
#print "DAT = @$row[1]\n";
$dat = @$row[1];
}
#
# SuperDAT version which has both Engine and DAT.
if (@$row[0] =~ /SuperDat File for v4x \(DAT \+ Engine\)/) {
#print "Superdat = @$row[1]\n";
$superdat = @$row[1];
}
#
# Engine only Version.
if (@$row[0] =~ /Superdat File for v4x \(Intel Engine only\)/) {
$engine = @$row[1];
}
#print " ", join(' , ', @$row), "\n";
}
}
return($dat, $superdat, $engine);
}