CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
reg. ex. in a perl module

 



keviny22
Novice

Aug 9, 2002, 1:43 PM

Post #1 of 5 (4288 views)
reg. ex. in a perl module Can't Post

I am using the perl module Net::Telnet::Cisco

I think that a regular expression in that module is causing me errors becuase it does not like a value in my script.

Here is the regular expression:


Code
 (-Prompt => '/(?m:^[\w.-]+\s?(?:\(config[^\)]*\))?\s?[\$#>]\s?(?:\(enable\))?\s*$)/') 



The value I am entering is "host-name> " #this is also the line that the perl script is erroring out on.

I think that the module is not dealing with the hyphen



I am very novice when it comes to regular expressions. Any help would be great.


davorg
Thaumaturge / Moderator

Aug 10, 2002, 1:28 AM

Post #2 of 5 (4281 views)
Re: [keviny22] reg. ex. in a perl module [In reply to] Can't Post

That's not the problem. The relevant part of the regex is [\w.-]+ which matches word characters (letters, digits and underscores), dots and hyphens.

Your problem must be elsewhere. What errors are you getting?

--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks


keviny22
Novice

Aug 10, 2002, 7:25 AM

Post #3 of 5 (4279 views)
Re: [davorg] reg. ex. in a perl module [In reply to] Can't Post


Code
  

#! /usr/local/bin/perl

use strict;
use Net::Telnet::Cisco;

my $strPassword =
'p@ssw0rd';
my $strLocalDir =
"my-local-director";
my $strLog =
"ldTelnet.log";
my $ptrTelnet;
my @strOutput;

if ($ptrTelnet = Net::Telnet::Cisco->new(Host => $strLocalDir,Timeout => 10, Input_log => $strLog))
{
$ptrTelnet->login(Password => $strPassword);
$ptrTelnet->cmd(
'terminal length 0');
@strOutput = $ptrTelnet->cmd(
'show failover');
$ptrTelnet->close;
}
else
{
print STDERR
"Failed to create telnet object.\n";
}
foreach (@strOutput)
{
print $_;
}



The Error I am getting:

pattern match timed-out at telnettest.pl line 13


davorg
Thaumaturge / Moderator

Aug 10, 2002, 10:50 AM

Post #4 of 5 (4277 views)
Re: [keviny22] reg. ex. in a perl module [In reply to] Can't Post

Line 13 looks like it's the call to "login". But I can't find that error message in the Net::Telnet::Cisco code.

Have you tried turning the $DEBUG flag on (I think you have to edit the value in the Cisco.pm file). That might give you more clues.

Failing that, try stepping thru the program in the Perl debugger.

--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks


keviny22
Novice

Aug 10, 2002, 11:22 AM

Post #5 of 5 (4275 views)
Re: [davorg] reg. ex. in a perl module [In reply to] Can't Post

I thought it was with the password line (line 13) also. To test my theory I used the wrong password and the script failed saying invalid password, so that tells me the script is getting past the password line. I also set the script to dump to an Input log, which adds all information returned to a log file. In the log, it shows that it successfully logs in. The last line in the log is the command prompt, which looks like: 'my-local-director>' , that is why I actually think the script is having troubles with line 14.

Thank for the help.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives