Beginner Regular Expression Question

2003-03-20 Thread Lupi, Guy
I am trying to figure out how to specify or in a regular expression.
Basically, I am specifying the Prompt portion of a telnet session using
Net::Telnet, and I want to match several possible strings that would make up
the prompts.  An explanation below:

'/br[0-9][0-9]/' or '/mar[0-9][0-9]/' or '/tr[0-9][0-9]/' or
'/ber[0-9]/'

Does anyone know if this can be done, and if so how?  Thanks.

Guy H. Lupi


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: :Telnet Script Issue

2003-03-07 Thread Lupi, Guy
Ok, I used Input_Log to debug, and I got the following:

User Access Verification

Username: glupi
Password: 
br01-nyc1.nyenable
Password: 
br01-nyc1.ny#show ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
   D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
   N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
   E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
   i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter
area
   * - candidate default, U - per-user static route, o - ODR
   P - periodic downloaded static route

Gateway of last resort is 

  is variably subnetted, 2 subnets, 2 masks
C   is directly connected, FastEthernet1/0
Cis directly connected, Loopback1
  is subnetted, 1 subnets
S   [1/0] via 
  [1/0] via 
  is directly connected, FastEthernet0/0
  is subnetted, 1 subnets
Cis directly connected, FastEthernet1/0
C is directly connected, FastEthernet0/0
S*   0.0.0.0/0 [1/0] via 
br01-nyc1.ny#

The script is doing exactly what I want it to do, with the exception of
printing the output of the command.  Is it possible that the script doesn't
recognize the occurence of br01-nyc1.ny# as the end of the command output?
If that is the case, how do I tell the script run the command show ip
route, and when you see br01-nyc1.ny# again the output is finished?
Thanks for the help.


-Original Message-
From: Allegakoen, Justin Devanandan
[mailto:[EMAIL PROTECTED]
Sent: Thursday, March 06, 2003 7:23 PM
To: [EMAIL PROTECTED]
Subject: RE: :Telnet Script Issue


---8--
I was able to resolve my issues with Net::Telnet not working, thank you to
everyone who replied to my post.  Now I have something different.  Below is
a script that I wrote, it telnets to a Cisco router, goes into enable mode,
and is supposed to print the output of a show ip route command.  The issue
is that the script times out at line 13, which is where it is supposed to
send the command.  I know that the telnet is connecting, and the script is
authenticating, because if it wasn't it would time out way before line 13
(at least I hope that is correct).  Can anyone tell me why it is timing out?
I thought that maybe it was because there was no newline at the end of line
13, but supposedly when using cmd there is an automatic newline appended to
the string.  I would appreciate any help.
---8--

99% of time out issues occur with Net::Telnet because the prompt
was not matched correctly.

Do a search on AS mailing lists for Net::Telnet and you will see other
peoples woes with this.

What I suggest you do is turn the logging on, and see what the prompt
actually is. (Its also a good idea to turn strict and warnings on):-

use strict;
use warnings;

my $t = new Net::Telnet (Timeout = 40, Dump_Log = C:/Temp/Err.txt);


If you cant match the prompt that it requires, send us the output
and one of us will write a regexp for you.

HTH

Just in
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: :Telnet Script Issue

2003-03-07 Thread Lupi, Guy
Excellent, I set the prompt value to be correct, and it now works well.
Thanks for the help!

-Original Message-
From: Thomas, Mark-BLS CTR [mailto:[EMAIL PROTECTED]
Sent: Friday, March 07, 2003 8:57 AM
To: Lupi, Guy; [EMAIL PROTECTED]
Subject: RE: :Telnet Script Issue


Guy Lupi wrote:
 Is it 
 possible that the script doesn't recognize the occurence of 
 br01-nyc1.ny# as the end of the command output?

Yes, the prompt could have been set incorrectly.

 If that is 
 the case, how do I tell the script run the command show ip 
 route, and when you see br01-nyc1.ny# again the output is 
 finished?

That's what the prompt is for! $t-cmd() uses the prompt to
determine the end of output.

Set your prompt to a proper value and it will work.


-- 
Mark Thomas[EMAIL PROTECTED]
Internet Systems Architect User Technology Associates, Inc.

$_=q;KvtuyboopuifeyQQfeemyibdlfee;; y.e.s. ;y+B-x+A-w+s; ;y;y; ;;print;;
 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Net::Telnet Script Issue

2003-03-06 Thread Lupi, Guy
I was able to resolve my issues with Net::Telnet not working, thank you to
everyone who replied to my post.  Now I have something different.  Below is
a script that I wrote, it telnets to a Cisco router, goes into enable mode,
and is supposed to print the output of a show ip route command.  The issue
is that the script times out at line 13, which is where it is supposed to
send the command.  I know that the telnet is connecting, and the script is
authenticating, because if it wasn't it would time out way before line 13
(at least I hope that is correct).  Can anyone tell me why it is timing out?
I thought that maybe it was because there was no newline at the end of line
13, but supposedly when using cmd there is an automatic newline appended to
the string.  I would appreciate any help.


use Net::Telnet();
$t = new Net::Telnet;
$t-open(x.x.x.x);
$t-waitfor('/Username:/');
$t-print(glupi);
$t-waitfor('/Password:/');
$t-print(neteng1283);
$t-waitfor('/br01-nyc1.ny/');
$t-print(enable);
$t-waitfor('/Password:/');
$t-print(neteng1283);
$t-waitfor('/br01-nyc1.ny#/');
@lines = $t-cmd(show ip route);
print @lines;



Guy H. Lupi


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Having problems with Net::Telnet

2003-03-04 Thread Lupi, Guy
I should have included that in my original message, I copied this from a
website:

use Net::Telnet();
$telnet = new Net::Telnet (Timeout = 10,
 Errmode = 'die');
$telnet -open('198.207.193.112');
$telnet -waitfor('Password:')

-Original Message-
From: Scot Robnett [mailto:[EMAIL PROTECTED]
Sent: Monday, March 03, 2003 8:21 PM
To: Lupi, Guy; [EMAIL PROTECTED]
Subject: RE: Having problems with Net::Telnet


Show us the code?




-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of
Lupi, Guy
Sent: Monday, March 03, 2003 5:22 PM
To: '[EMAIL PROTECTED]'
Subject: Having problems with Net::Telnet


Please excuse me if this is an extremely basic question, this is my first
post and I am a beginner, but I can't seem to get Net::Telnet to work.  I am
getting the following error when I try to run a script using the Net::Telnet
module.

Can't locate object method new via package Net::Telnet (perhaps you
forgot t
o load Net::Telnet?) at telnet.txt line 2.

I have looked on the net, and I found some advice, but nothing I do seems to
work.  I ran the libnet.cfg file, and ran ppm to install net-telnet, and
telnet.pm is definitely in my Perl installation.  I think my code is
correct, I copied it exactly from a website and simply replaced their IP
address with my own.  I am running ActivePerl on a Windows XP workstation.
I am a beginner, so be gentle :).



Guy H. Lupi


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Having problems with Net::Telnet

2003-03-04 Thread Lupi, Guy
I did that, here is the output that was returned.

C:\Perlppm install Net::Telnet
Searching for 'Net::Telnet' returned multiple results. Using 'search'
instead...

Searching in Active Repositories
  1. Net-Telnet   [3.03] Interact with TELNET port or other TCP
ports
  2. Net-Telnet-Cisco [1.10] automate Cisco management
  3. Net-Telnet-Netscreen [1.01] interact with a Netscreen firewall

C:\Perlppm install Net-Telnet
Note: Package 'Net-Telnet' is already installed.

Install 'Net-Telnet' version 3.03 in ActivePerl 5.8.0.804.

Successfully installed Net-Telnet version 3.03 in ActivePerl 5.8.0.804.

Then I tried to run my script and I got the same error message.


-Original Message-
From: Thomas_M [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 04, 2003 8:06 AM
To: Lupi, Guy
Cc: Perl-Win32-Users (Perl-Win32-Users)
Subject: RE: Having problems with Net::Telnet


 Can't locate object method new via package Net::Telnet 
 (perhaps you forgot t o load Net::Telnet?) at telnet.txt line 2.

I'm not sure why nobody told you this yet, but this error means you need to
install the Net::Telnet module. From a command prompt, type ppm install
Net::Telnet.


-- 
Mark Thomas[EMAIL PROTECTED]
Internet Systems Architect User Technology Associates, Inc.

$_=q;KvtuyboopuifeyQQfeemyibdlfee;; y.e.s. ;y+B-x+A-w+s; ;y;y; ;;print;;
 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs