P
Patrick Paquet
Hello everyone,
Not my first posting here, but the first one since I've read the
Posting Guidelines (hope I got it right)
I read the docs on 'use strict', but still don't quite understand why
I get "Can't use string ("Machine1") as a HASH ref while "strict refs"
in use at ... line 43".
Also ran it with 'Perl -w' but that did not return any info regarding
the "Can't use string" error, just some "Use of uninitialized value
at..." (which I don't get either btw).
All the subroutines return data as expected and the program executes
normally until line 43. This program is a bit lengthy to post in it's
entirety, so I snipped all irrelevant lines and modified the code so
that what is below replicates the error as I see it in the normal
version.
I am running on WinNT, perl version 5.005_02, ActivePerl(509). I know
it's old, but since I don't manage the script servers here I'm using
the same version as the server.
If there's anything missing from this, it's purely accidental, and I
will do my best to provide all necessary information.
Thanks for your time.
Patrick Paquet
###################################################
use strict;
use Win32::ODBC;
use File::Find;
use Win32API::Net;
use Win32::NetAdmin;
use Net:ing;
use Net::hostent;
use Socket;
my @ListDOM = qw/Machine1 Machine2 Machine3/; # This list is pulled
directly from the SAM on the PDC
my ($Machine, $ValeurCle, %MachineInfo, $CheckMachine, $Ping,
$ReverseLookup, $AdresseIP, $INTAdresseIP);
foreach $Machine (@ListDOM)
{
$CheckMachine = 0;
# %MachineInfo = &ReadSQL($ConnectionSQL,$Machine); # Commented to
allow
execution, otherwise runs OK
if ($MachineInfo{MachineName} ne $Machine) # Existe pas dans la
base
{
$CheckMachine = 1;
print "$Machine n'existe pas dans la base.($CheckMachine)\n";
}
$ValeurCle = 123456; #&GetValeurCle($Machine);
if ($MachineInfo{Valeur_CiPatches} != $ValeurCle)
{
$CheckMachine = 1;
print "$Machine: valeur cle differente.($CheckMachine)\n";
}
($Ping,$ReverseLookup,$AdresseIP)=("OK","OK","10.10.10.10");#&GetIP($Machine);
if ($MachineInfo{IP_address} ne $AdresseIP)
{
$CheckMachine = 1;
print "$Machine: adresse IP differente.($CheckMachine)\n";
}
if ($CheckMachine == 0)
{
print "Base a jour pour $Machine, machine suivante...\n\n";
}
else
{
print "Checks values on workstation...\n\n";
### ERROR REPORTED ON FOLLOWING LINE
&EcritureSQL(%$Machine);#Passes HASH to subroutine to write
to SQL db
###
} # Fin de la verification d'une machine
} # Fermeture de la boucle de verification des machines, toutes
les machines ont etes processe
sub EcritureSQL # Ecriture des infos dans la base SQL
{
# Doesn't do much at this point, until I get that error sorted out.
my ($Key, $Value, $Pause);
my %InfosMachine = %_;
while (($Key, $Value)=each %InfosMachine){print "Key:$Key \->
Value: $Value\n";}
$Pause = <STDIN>;
}
Not my first posting here, but the first one since I've read the
Posting Guidelines (hope I got it right)
I read the docs on 'use strict', but still don't quite understand why
I get "Can't use string ("Machine1") as a HASH ref while "strict refs"
in use at ... line 43".
Also ran it with 'Perl -w' but that did not return any info regarding
the "Can't use string" error, just some "Use of uninitialized value
at..." (which I don't get either btw).
All the subroutines return data as expected and the program executes
normally until line 43. This program is a bit lengthy to post in it's
entirety, so I snipped all irrelevant lines and modified the code so
that what is below replicates the error as I see it in the normal
version.
I am running on WinNT, perl version 5.005_02, ActivePerl(509). I know
it's old, but since I don't manage the script servers here I'm using
the same version as the server.
If there's anything missing from this, it's purely accidental, and I
will do my best to provide all necessary information.
Thanks for your time.
Patrick Paquet
###################################################
use strict;
use Win32::ODBC;
use File::Find;
use Win32API::Net;
use Win32::NetAdmin;
use Net:ing;
use Net::hostent;
use Socket;
my @ListDOM = qw/Machine1 Machine2 Machine3/; # This list is pulled
directly from the SAM on the PDC
my ($Machine, $ValeurCle, %MachineInfo, $CheckMachine, $Ping,
$ReverseLookup, $AdresseIP, $INTAdresseIP);
foreach $Machine (@ListDOM)
{
$CheckMachine = 0;
# %MachineInfo = &ReadSQL($ConnectionSQL,$Machine); # Commented to
allow
execution, otherwise runs OK
if ($MachineInfo{MachineName} ne $Machine) # Existe pas dans la
base
{
$CheckMachine = 1;
print "$Machine n'existe pas dans la base.($CheckMachine)\n";
}
$ValeurCle = 123456; #&GetValeurCle($Machine);
if ($MachineInfo{Valeur_CiPatches} != $ValeurCle)
{
$CheckMachine = 1;
print "$Machine: valeur cle differente.($CheckMachine)\n";
}
($Ping,$ReverseLookup,$AdresseIP)=("OK","OK","10.10.10.10");#&GetIP($Machine);
if ($MachineInfo{IP_address} ne $AdresseIP)
{
$CheckMachine = 1;
print "$Machine: adresse IP differente.($CheckMachine)\n";
}
if ($CheckMachine == 0)
{
print "Base a jour pour $Machine, machine suivante...\n\n";
}
else
{
print "Checks values on workstation...\n\n";
### ERROR REPORTED ON FOLLOWING LINE
&EcritureSQL(%$Machine);#Passes HASH to subroutine to write
to SQL db
###
} # Fin de la verification d'une machine
} # Fermeture de la boucle de verification des machines, toutes
les machines ont etes processe
sub EcritureSQL # Ecriture des infos dans la base SQL
{
# Doesn't do much at this point, until I get that error sorted out.
my ($Key, $Value, $Pause);
my %InfosMachine = %_;
while (($Key, $Value)=each %InfosMachine){print "Key:$Key \->
Value: $Value\n";}
$Pause = <STDIN>;
}