nested telnet
igoryonya opened this issue · 1 comments
I need to monitor a router, that's not visible directly, but only from an other router, so, I telnet to the router, visible by me directly, then I issue a nested telnet command to a remote router form the router, that I am in telnet session currently, but it doesn't work that way. I guess, it hangs on user name/password prompts:
local_router> telnet <remote_router_ip>
read timed-out at /usr/local/share/perl/5.26.1/Net/CLI/Interact/Transport/Wrapper/Net_Telnet.pm line 33Execution of finally() block CODE(0x5559bd372488) resulted in an exception, which CAN NOT BE PROPAGATED due to fundamental limitations of Perl. Your program will continue as if this event never took place. Original exception text follows:
read timed-out at /usr/local/share/perl/5.26.1/Net/CLI/Interact/Transport/Wrapper/Net_Telnet.pm line 33
Hi, yes the module is hanging waiting for the next command line prompt as it's in a mode where there is one command, then some output, then a prompt.
You can write a telnet macro:
macro telnet_to
send telnet %s
match user
send %s
match pass
send %s
match generic
user and pass are existing prompts known to the module:
https://github.com/ollyg/Net-CLI-Interact/blob/master/share/phrasebook/cisco/pb
and you run it like:
$s->macro('telnet_to', { params => ['desthost', 'username', 'password'] });
these guides should help:
https://metacpan.org/pod/distribution/Net-CLI-Interact/lib/Net/CLI/Interact/Manual/Cookbook.pod
https://metacpan.org/pod/distribution/Net-CLI-Interact/lib/Net/CLI/Interact/Manual/Phrasebook.pod
https://metacpan.org/pod/distribution/Net-CLI-Interact/lib/Net/CLI/Interact/Manual/Tutorial.pod
And note that the Net::CLI::Interact instance used in the manuals is available with the $s->nas()
method on the Net::Appliance::Session instance.