Anyone know why this regular expression search isn't working properly?
I'm using use Net::Telnet::Cisco; to populate the @output variable if that matters..
Sample contents of @output variable:
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.10.10.10, timeout is 2 seconds:
.May 16 16:30:26 CDT: Se2/1:23 DDR: rotor dialout [priority]
.May 16 16:30:26 CDT: Se2/1:23 DDR: Dialing cause ip (s=10.10.10.10, d=10.10.10.10)
.May 16 16:30:26 CDT: Se2/1:23 DDR: Attempting to dial 1233454567.....
Success rate is 0 percent (0/5)
ISDN connection to 10.10.10.10 (Test Site, USA) possibly successful
As you can see , the script should definitely find the substring 'Success' in @output above, but it doesn't. I've tried to not treat the string as a single line (by removing /s ) but the problem remains. I know this is really basic but I've poured over a lot of material on this topic and no variation of whatI've read has helped.
Thanks for any help..
I'm using use Net::Telnet::Cisco; to populate the @output variable if that matters..
Code:
#my $success = "Success rate is 0 percent";
my $success = "Success";
@output = $session->cmd(String => join (' ', 'ping', $ip),
Timeout => 20,
);
print @output; # ok to here..
# found the substring
if ($o =~ /$success/s)
{
print "ISDN connection to $ip ($desc) failed\n";
} else
# substtring not found
{
print "ISDN connection to $ip ($desc) possibly sucessful\n";
}
Sample contents of @output variable:
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.10.10.10, timeout is 2 seconds:
.May 16 16:30:26 CDT: Se2/1:23 DDR: rotor dialout [priority]
.May 16 16:30:26 CDT: Se2/1:23 DDR: Dialing cause ip (s=10.10.10.10, d=10.10.10.10)
.May 16 16:30:26 CDT: Se2/1:23 DDR: Attempting to dial 1233454567.....
Success rate is 0 percent (0/5)
ISDN connection to 10.10.10.10 (Test Site, USA) possibly successful
As you can see , the script should definitely find the substring 'Success' in @output above, but it doesn't. I've tried to not treat the string as a single line (by removing /s ) but the problem remains. I know this is really basic but I've poured over a lot of material on this topic and no variation of whatI've read has helped.
Thanks for any help..