Thread

Posted on Wed Jan 16 23:25:51 2008 by miky
Retriving the prompt
Hi, I'm writing code with this perl module to backup my configurations (Cisco first, then maybe other vendors) I just need to know how could I retrive the prompt of the router/switch. When I used Net::Telnet::Cisco is was
$session->lastprompt
Rgds
Direct Responses: 6886 | Write a response
Posted on Thu Jan 17 00:41:52 2008 by oliver in response to 6885
Re: Retriving the prompt
Hi Miky
You should be able to use lastprompt on the Net::Appliance::Session object itself.

Both Net::Telnet::Cisco and my module Net::Appliance::Session are derived from Net::Telnet. The last_prompt, lastline and other similar methods are from Net::Telnet so are automatically inherited by objects in the Net::Appliance::Session class. e.g.:

my $s = Net::Appliance::Session->new('hostname.example'); $s->connect(Name => 'username', Password => 'loginpass'); ...etc... $s->cmd('show access-list'); print $s->last_prompt;

Please see the Net::Telnet manual page for further details. I hope that helps :-)

regards,
oliver.
Direct Responses: 6888 | Write a response
Posted on Thu Jan 17 16:21:42 2008 by miky in response to 6886
Re: Retriving the prompt
Hi Oliver, I'm afraid this last prompt is not displayed with the Net::Appliance::Session module. I just copied and pasted your exemple modifying the host, user, and password. I also modified the command line so is would display the access-lists
print $s->cmd('show access-list');
So I'm sure it's logging on the router. the
print $s->last_prompt;
works successfully on net:telnet and net::telnet::cisco though Regards
Direct Responses: 6890 | Write a response
Posted on Sat Jan 19 23:34:30 2008 by oliver in response to 6888
Re: Retriving the prompt
Hi miky

Okay, I have found the problem, and I must apologise because there is a bug in Net::Appliance::Session!

I have just released a new version of the module, 0.19, which I think fixes this issue. You may have to wait a short time before it reaches your local CPAN mirror.

regards,
oliver.
Direct Responses: 6906 | Write a response
Posted on Mon Jan 21 18:59:07 2008 by miky in response to 6890
Re: Retriving the prompt
Hi Oliver, I tryed the new version and it works fine with the prompt. Thanx
Write a response