I have
just gotten a new Win2k PC with perl v5.6.1 and can not run the below script
which I could run on my old NT 4.0 PC running V5.005_03. The new
PC has Win32-Lanman [1.0.9.1] and Net-Ping [2.18]. What is happening is
that the script will run through the 1st machine in a text file, but on the
second machine the script will exit on the "$p = Net::Ping..." line.
I have debugged it to the point where if I rem out the
"if(Win32::Lanman::QueryServiceConfig..." block the script will run OK. It
will just ping machines, but do nothing else. If I just have the
QueryServiceConfig line and rem the lines below it the script still dies on the
second machine in the list on the "$p = Net::Ping...." line.
Does
anyone have an idea as to why this might be happening or better yet, how to
correct this?
foreach $server (@server) {
$server =~ s/\\\\//;
$p = Net::Ping->new("icmp");
$server =~ s/\\\\//;
$p = Net::Ping->new("icmp");
if (!$p->ping("$server")) {
sleep (5);
next;
}
foreach $service (@service) {
if(Win32::Lanman::QueryServiceConfig("\\\\$server", '', "$service", \%config)){
(Win32::Service::GetStatus("$server",$service ,\%status));
if($status{CurrentState} ne 4) {
&restart_service($server,$service,$badpc);
$list="$list"."$badpc\n";
$badpc=();
}
}
}
}
sleep (5);
next;
}
foreach $service (@service) {
if(Win32::Lanman::QueryServiceConfig("\\\\$server", '', "$service", \%config)){
(Win32::Service::GetStatus("$server",$service ,\%status));
if($status{CurrentState} ne 4) {
&restart_service($server,$service,$badpc);
$list="$list"."$badpc\n";
$badpc=();
}
}
}
}
