ryber has asked for the wisdom of the Perl Monks concerning the following question:
I have an application which uses Net::Telnet::Cisco to log in to various network devices, run some commands and parse the output. I have been trying to enhance the script to use SSH, but have run into problems due to the fact that the app uses threads.
I have attempted to do this using Net::Appliance::Session and Net::SSH::Perl, but neither appears to be thread safe. In each case I am able to write a simple test program which works, until I modify it so that the objects are instantiated from within a thread, in which case it consistently fails.
So now I am trying to use Net::SSH2. Does anyone have any experience using Net::SSH2 interactively with cisco devices or integrating it with Net::Telnet? What I would like to do is to pass an open Net::SSH2 connection to Net::Telnet::Cisco using Net::Telnet's fhopen() method. However, while the documentation for Net::SSH2::Channel says it is a tied filehandle, if I try to create one and hand it off to Net::Telnet, say like this (I tried with and without the commented line):
I get the following error:my $chan = $ssh2->channel(); #$chan->shell(); my $conn = Net::Telnet->new(Fhopen => $chan);
Can't locate object method "FILENO" via package "Net::SSH2::Channel" a +t /usr/lib/perl5/site_perl/5.8.8/Net/Telnet.pm line 560.
Does anyone have any experience of suggestions on this? Also, has anyone have any experience using the Pseudo Terminal available via $chan->pty()? If so, any suggestions on how I may be able to integrate Net::Telnet or Net::Telnet::Cisco using that?
Thanks in advance.
|
|---|