J
joe.henderson1@
All,
I run a mysql db 5.0.11. With a table that contains a few columns
defined as type "text" with indexes..
I running this on a Arch Linux 0.7.1.. 2.6.15 custom.. perl 5.8.8
I run some scripts to parse data from cisco/network devices using snmp
and telnet/ssh..
I retrieve the name, mac, serial, location, description, interfaces,
etc..
The problem I have is the names I recieve from the
devices I run threw a "clean subroutine"..
##########
sub clean
{
my $debug = 0;
my $item = $_[0];
$item =~ s/^\s+//; #remove Leading whitespace
$item =~ s/\s+$//; #remove trailing whitespace
$item =~ s/\r/ /g; #remove those Damn ^M
$item =~ s/\f/ /g; #remove those Damn ^M
$item =~ s/\t/ /g; #remove those Damn ^M
$item =~ s/\n/ /g; #remove those Damn ^M
$item =~ s/\s+/ /g; #replace multiple spaces with one
chomp($item); #remove newline character
return $item;
}
##########
And for some reason when I compare to different names
From DB: $name = "00a45fde0032(sw1)"
And the name I pulled from the device $name: "00a45fde0032(sw1)"
and compare them for exact match
##########
if($name eq $mname)
{ print "MATCH ON NAME: \"$name\" MNAME: \"$mname\"\n"; }
else
{ print "NO MATCH\n"; }
##########
Nothing happens.. No Match.
However when I did a
##########
if($name == $mname)
{ print "MATCH ON NAME: \"$name\" MNAME: \"$mname\"\n"; }
else
{ print "NO MATCH\n"; }
##########
I recieved an error stating "cannot equal on non numeric" which is
what I expected.. However it showed a hidden character of
"MNAME: "00a45fde0032(sw1)\o"
What does the "\o" mean? I have never seen this before..
In the variable their has to be hidden characters that I cannot see.
I thought about converting the string to hex then back to see if
any characters show up..
Or "$item =~ s/[^ A-Za-z0-9\-\:\.\(\)\@]//g;"
A note.. I use the "sub clean" for everthing I receive from my
scripts.. And then insert/update/replace into the database..
I don't know if the column type is causing this error or the
devices that are returning the value.. Due to I cannot see the
hidden values...
If their is a better way of "cleaning" the variables please let me
know..
Joe
I run a mysql db 5.0.11. With a table that contains a few columns
defined as type "text" with indexes..
I running this on a Arch Linux 0.7.1.. 2.6.15 custom.. perl 5.8.8
I run some scripts to parse data from cisco/network devices using snmp
and telnet/ssh..
I retrieve the name, mac, serial, location, description, interfaces,
etc..
The problem I have is the names I recieve from the
devices I run threw a "clean subroutine"..
##########
sub clean
{
my $debug = 0;
my $item = $_[0];
$item =~ s/^\s+//; #remove Leading whitespace
$item =~ s/\s+$//; #remove trailing whitespace
$item =~ s/\r/ /g; #remove those Damn ^M
$item =~ s/\f/ /g; #remove those Damn ^M
$item =~ s/\t/ /g; #remove those Damn ^M
$item =~ s/\n/ /g; #remove those Damn ^M
$item =~ s/\s+/ /g; #replace multiple spaces with one
chomp($item); #remove newline character
return $item;
}
##########
And for some reason when I compare to different names
From DB: $name = "00a45fde0032(sw1)"
And the name I pulled from the device $name: "00a45fde0032(sw1)"
and compare them for exact match
##########
if($name eq $mname)
{ print "MATCH ON NAME: \"$name\" MNAME: \"$mname\"\n"; }
else
{ print "NO MATCH\n"; }
##########
Nothing happens.. No Match.
However when I did a
##########
if($name == $mname)
{ print "MATCH ON NAME: \"$name\" MNAME: \"$mname\"\n"; }
else
{ print "NO MATCH\n"; }
##########
I recieved an error stating "cannot equal on non numeric" which is
what I expected.. However it showed a hidden character of
"MNAME: "00a45fde0032(sw1)\o"
What does the "\o" mean? I have never seen this before..
In the variable their has to be hidden characters that I cannot see.
I thought about converting the string to hex then back to see if
any characters show up..
Or "$item =~ s/[^ A-Za-z0-9\-\:\.\(\)\@]//g;"
A note.. I use the "sub clean" for everthing I receive from my
scripts.. And then insert/update/replace into the database..
I don't know if the column type is causing this error or the
devices that are returning the value.. Due to I cannot see the
hidden values...
If their is a better way of "cleaning" the variables please let me
know..
Joe