For some reason Perl is giving me and unitialized variable error when attempting to take a value out of a hash. Is there any other way of getting the data out of the hash? That same code worked before(gathering port data from a switch) so I'm wondering why it isn't working this time.
The exact output for one xml element is as follows:
Pairname is: RP261
value is HASH(0x10b0060)
Use of uninitialized value in concatenation (.) or string at time_script.pl line 56.
StatA is
#!/usr/bin/perl -w
#Status Legend : 1=psNotInstalled,2=psAvailable,3=psBlocked,4=psUnavai
+lable,
#5=psLinkFailure,6=psLinkFailLOL,7=psIntDiags, 8=psExtLoop,9=psPortFai
+l,
#10=psSR,11=psLR,12=psInaccessible,13=psInactive
### This script developed by Bill Ruehl, July 2007
### Version 1.0 This is version 1 of the time check script
use strict;
#modules used
use XML::Simple;
use Net::SNMP;
use XML::Parser;
use XML::Parser::Expat;
our ($data, $xml, $e, $value, $IPAddressA, $OID, $session, $error, $st
+atA,$resmsg);
#create object
# Hard Code OID for port status info
$OID ="1.3.6.1.4.1.289.2.1.1.2.1.11" ;
#Hard Code OID for metrics info
#instantiate a parser
$xml = new XML::Simple;
open LOG, ">>/home/pbkhk/test/log.txt";
# read the XML file
$data = $xml->XMLin("/home/pbkhk/test/timetest.xml");
print LOG "This iteration run at: " . localtime() . "\n" ;
foreach $e (@{$data->{PairedDevices}})
#Do actions that require use of XML data in this loop possibly
#call SNMP data gathering and reporting
{
print "Pairname is: " . $e->{PairName} . "\n ";
print LOG "Pairname is: ". $e->{PairName} . "\n ";
$IPAddressA = $e->{DeviceA}->{IPAddress} ;
#print "IpAddressA is " . $IPAddressA . "\n";
#print "IpAddressB is " . $IPAddressB . "\n";
if ($e->{ExclusionIndicator} ne "y") #Check to see if host sh
+ould be ignored
{
#print "SNMP test for DeviceA \n";
($session,$error) = Net::SNMP->session(Hostname => $IPAddr
+essA,
Community => "public");
}
$value = $session->get_request($OID);
print LOG "request error " . $session->error unless (defin
+ed $value);
$session->close;
$statA = $value->{$OID};
print "value is $value \n" ;
print "StatA is $statA \n";
#print "Date and Time for : $e->{PairName} was $statA \n"
+;
#print LOG "Date and Time for : $e->{PairName} was $statA \n
+";
}
close LOG;
Thanks,