| Store | Cart

RE: timed-out waiting for command prompt

From: ibrahim <ibra...@aramco.com>
Wed, 27 Nov 2002 13:41:51 +0300
Please help

The below code worked fine and gave the desired result many time but
suddenly started to return the same earlier error message "timed-out
waiting for command prompt at perliaa5b.pl line 8". I used to get this
message before 
Until I got a help from lgb...@bb.com.br to add the Prompt setting to
the code as it appear below. Please help. Thank you.


use Net::Telnet;
my $Telnet = new Net::Telnet; 
my $InHandle = $Telnet->input_log("inlog.txt"); 
my $OutHandle = $Telnet->output_log("outlog.txt"); 
my $prmpt = '/[\w().-]*[\$#>:.]\s?(?:\(enable\))?\s*$/'; 
$telnet = new Net::Telnet (Timeout=>40, Prompt => $prmpt,
Errmode=>'die'); 
$telnet->open('xx.xx.xxx.xxx'); 
$telnet->login('user','user'); 
@lines= $telnet->cmd("Networking"); 
@lines= $telnet->cmd("IP");
@lines= $telnet->cmd("ipmac");
print STDOUT @lines;
$telnet->close;


Not even the following 

$telnet->open('XX.XXX.XXX.XXX');
$telnet->waitfor('/login: $/i');
$telnet->print('user');
$telnet->waitfor('/password: $/i');
$telnet->print('user');
$telnet->waitfor('/\$ $/i');

-----Original Message-----
From: perl...@listserv.ActiveState.com
[mailto:perl...@listserv.ActiveState.com] On Behalf Of
lgb...@bb.com.br
Sent: Tuesday, November 19, 2002 6:15 PM
To: ibra...@aramco.com
Cc: perl...@listserv.ActiveState.com;
perl...@listserv.ActiveState.com
Subject: RE: timed-out waiting for command prompt


I'm not sure how you can find out the exact prompt, asides going into
the
equipment, via telnet, and discovering it yourself. Maybe someone else
might be able to help you out with that.  What I do is the following:


      my $prmpt = '/[\w().-]*[\$#>:.]\s?(?:\(enable\))?\s*$/';
      my $t = new Net::Telnet (Timeout => 10, Prompt => $prmpt);

That way, I'm pretty sure I get most prompts that are out there.
The way Net::Telnet works is that it looks for a "$", "#", ">", ":",
etc..
(as defined in $prmpt) so it knows when its received the correct prompt.
That, to my knowledge can be machine dependent or dependent on whomever
may
have set up the equipment. Most equipments (switches, routers) allow you
to
change the prompt character.

Uh...  That's about all I know regarding Telnet and prompts...

Really hope this helps...  :c)

Cheers,

/Luiz George


 

 

                                                                 Para:
lgb...@bb.com.br                          
               ibrahim <ibra...@aramco.com>               cc:
perl...@listserv.ActiveState.com 
               Enviado Por:
Assunto:     RE: timed-out waiting for command    
               perl...@listserv.ActiveStat        prompt

               e.com

 

 

               19/11/02 13:23 ZE3

               Responder a ibrahim.attiah

 

 





Thanks a lot for your support. Please note that I am new in PERL
therefore can you please give me more details? How can find out the
existing prompt type in the target machine (the network switch which I
am trying to access) and how can I change it?



Thank you again.
 -----Original Message-----
From: lgb...@bb.com.br [mailto:lgb...@bb.com.br]
Sent: Monday, November 18, 2002 6:47 PM
To: Attiah, Ibrahim A
Cc: perl...@listserv.ActiveState.com;
perl...@listserv.ActiveState.com
Subject: Re: timed-out waiting for command prompt


Hummm....  I believe you might have to set your prompt to whatever the
actual prompt is on the equipment you're
  telnet'ing to.

cheers,

/LG






                                                                 Para:
perl...@listserv.ActiveState.com
               "Attiah, Ibrahim A"                               cc:

               <ibra...@aramco.com>
Assunto:     timed-out waiting for command prompt
               Enviado Por:

               perl...@listserv.ActiveStat

               e.com





               18/11/02 10:01 ZE3








Please help.

use Net::Telnet;
  $telnet = new Net::Telnet ( Timeout=>10, Errmode=>'die');
  $telnet->open('xx.xxx.xx.xxx');
  $telnet->login('loginid', 'password');
  print $telnet->cmd('who');

The previous code was working fine and give me the result. Now I am
getting the following message when I execute the script:

C:\Perl\bin>perl perliaa3a.pl
timed-out waiting for command prompt at perliaa3a.pl line 4

The IP address is for a network switch which is on and I can access it
without the script.

Even when I increased the timeout or I changed the IP address, it still
give the same error.

Thank you.
_______________________________________________
Perl-Win32-Users mailing list
Perl...@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs




_______________________________________________
Perl-Win32-Users mailing list
Perl...@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs




_______________________________________________
Perl-Win32-Users mailing list
Perl...@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Recent Messages in this Thread
ibrahim Nov 27, 2002 10:41 am