Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

How do I telnet into a machine and then to a third one?

( #166997=categorized question: print w/ replies, xml ) Need Help??
Contributed by smoss on May 16, 2002 at 13:07 UTC
Q&A  > network programming


Description:

I need to run a script using Net::Telnet which logs into one machine and then into a third machine (because of a firewall) and pull info of the third server. My script always fails after the login to the second machine.

How should I initiate the telnet session on the second machine correctly?

Answer: How do I telnet into a machine and then to a third one?
contributed by loosifer

Use Expect.pm or expect (the separate binary). Either should work for your purposes. Expect (the binary) is a strange language to use, so you might as well use Expect.pm if it will do everything you want.

As I recall, it works fine for telnet, but it can have problems with SSH. I have used it for doing nested telnets, and once you get past the initial barrier of how it works, it's pretty easy to use.

Answer: How do I telnet into a machine and then to a third one?
contributed by Marza

I don't think this is possible. You are expecting the second telnet session to be handled by Net::Telnet. It won't.

The reason is that you are running telnet as a command line tool over Net::Telnet's telnet session. Net::Telnet doesn't know that the second telnet session exists. All it knows is that you sent some keystrokes to the remote server. The remote server is the one initiating and managing the telnet session.

Please (register and) log in if you wish to add an answer



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others scrutinizing the Monastery: (5)
    As of 2014-09-22 21:29 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (202 votes), past polls