In the context of ssh, "tunnelling" has a very specific meaning. I suspect it's not the meaning you're using.

Personally, I avoid telnet as much as possible - it's both insecure (though likely not an issue in your case, I can't be sure) and annoying, compared to ssh. With ssh, I can tell it to run a single command, so it connects, runs the command, and exits, and so it behaves pretty much like running the command locally, at least from the perspective of using open to pipe from it, or IPC::Open3 to read its stdout and stderr (which is actually how I do it). Because you can't avoid the remote shell parsing the command, it is still a little bit annoying, but not like running telnet where you have to interact with a fully interactive shell, worrying about things like prompts (which can be vastly different depending on who you're running as) and pseudo-terminals (pty). With ssh, I run only one command, and I know it's finished because the subprocess exited. With telnet, it's much more annoying.

Ok, so that little rant out of the way, what I think you want is to use Expect with a command of 'ssh', '-e', 'telnet router'. I believe Expect can set up the full pty, which simplifies things for you, and then you can interact with the shell on the router just as if it were local. Note that I'm assuming passwordless ssh, though you probably can feed in the password via Expect, too.


In reply to Re: SSH Tunneling by Tanktalus
in thread SSH Tunneling by xomo

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.