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):

my $chan = $ssh2->channel(); #$chan->shell(); my $conn = Net::Telnet->new(Fhopen => $chan);
I get the following error:
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.


In reply to Using Net::SSH2 with Net::Telnet::Cisco by ryber

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.