- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Perl & Telnet module regex
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-06-2006 05:19 AM
тАО11-06-2006 05:19 AM
Perl & Telnet module regex
Trying...
Connected to host1.
Escape character is '^]'.
(need to hit cntr B)
I@12:01:48 LOG ON
ENTER LOGON ID: ID1 (need to hit control c)
ENTER PASSWORD: (need to hit control c)
R@12:03:37 SIOO008 JOB 0020 11/06/06 SWITCHDS1
ID1 LOGGED ON TERMINAL 20 AT 12:03:37 ON 11/06/06
(Here the cursor is at a blank line, and I hit CNRTL B to get the next prompt of:
I@12:12:57
Here is my script:
#!/usr/bin/perl
use Net::Telnet;
$t = new Net::Telnet (timeout => 10,
Errmode => 'die',
Host => 'host1',
Port => '2008');
$t->open ();
$t->waitfor('/^Escape character is/');
$t->print ('^B');
$t->waitfor('/^I@[0-9]{2}:[0-9]{2}:[0-9]{2}/');
$t->print ('LOG ON^C');
$t->waitfor('/ENTER LOGON ID: /');
$t->print ('ID1^C');
$t->waitfor('/ENTER PASSWORD: /');
$t->print ('PASSWORD123^C');
*how can I monitor at what step I am failing at?
When I run it complains about not match the Escape character...:
pattern match read eof at telnet.pl line 9
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-06-2006 05:31 AM
тАО11-06-2006 05:31 AM
Re: Perl & Telnet module regex
This seems like a follow-on to your earlier post:
https://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1073695
I suggest that you use the notation provided therein.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-06-2006 05:35 AM
тАО11-06-2006 05:35 AM
Re: Perl & Telnet module regex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-06-2006 05:42 AM
тАО11-06-2006 05:42 AM
Re: Perl & Telnet module regex
I think that part of your problem is that your writes (print) are not producing a newline.
Either explicitly add it ("\n") or add the '-l' switch to your interpreter line:
#!/usr/bin/perl -l
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-06-2006 06:05 AM
тАО11-06-2006 06:05 AM
Re: Perl & Telnet module regex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-06-2006 06:46 AM
тАО11-06-2006 06:46 AM
Re: Perl & Telnet module regex
Because when I log in manually, the propmt is actually two lines lower after the Escape character...
Connected to host1.
Escape character is '^]'.
#the prompt is actually here(need to hit cntr B)
I@12:01:48 LOG ON (cntr c)
So I tried...
$t->open ();
$t->waitfor('/^$/');
$t->print ("\cB");
I still get an error...
pattern match read eof at telnet.pl line 11
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-06-2006 07:15 AM
тАО11-06-2006 07:15 AM
Re: Perl & Telnet module regex
It apppears that the newline is appended by default. Perhaps this helps you a bit:
http://search.cpan.org/~jrogers/Net-Telnet-3.03/lib/Net/Telnet.pm
For tracing purposes, you could add 'warn' calls:
...
waitfor( ... ) or warn "can't read...";
...
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-23-2006 01:23 PM
тАО11-23-2006 01:23 PM
Re: Perl & Telnet module regex
Did it quicker with expect that was called by perl
Appreciate all the help though!