Loading ...
Sorry, an error occurred while loading the content.

[PBML] Re: Telnet ... doesn't work

Expand Messages
  • Damien Carbery
    Have you tried with prompt()? $prev = $obj- prompt($matchop); I ve never used this module because it is not in the standard ActiveState Perl distribution but I
    Message 1 of 2 , Apr 25, 2001
    • 0 Attachment
      Have you tried with prompt()?
      $prev = $obj->prompt($matchop);
      I've never used this module because it is not in the standard
      ActiveState Perl distribution but I read about it and began a
      script before I realised.

      Maybe you could sent all the I/O to a log (with dump_log or
      output_log) - something to see what the remote machine is doing.

      --- In perl-beginner@y..., Jeremiah Megie <jmegie81@e...> wrote:
      > Yes, the prompt is different, but I have tried it with a waitfor
      statement
      > as well:
      >
      >
      > #!/usr/bin/perl
      > use Net::Telnet;
      >
      > &add_dns9
      >
      > sub add_dns9
      > $host = 'dns9.domain.net';
      > $username = 'actualuserid';
      > $passwd = 'actualpasswd';
      > $t = Net::Telnet->new( Timeout => 10,
      > Host => $host,
      > Dump_Log => 'dump.log'
      > Input_log => 'input.log');
      > $t->login($username, $passwd);
      > $t->waitfor(/\[root\@dns9 actualuserid\]#/i);
      > $t->close;
      > }
      >
      > But, even without the waitfor statement, it should login, and the
      close the
      > session right away without waiting for any kind of prompt. Or, at
      least I'm
      > assuming that it should close right away.
      >
      > One other thing, and this may be the cause, do I need to escape out
      for
      > sqaure brackets like I did? Or, should I remove the esacape
      characters? I
      > know that @ symbol must be escaped, but I can't remember if the
      square
      > brackets need to be. I'm pretty sure though.
      >
      >
      > Jeremiah
      >
      >
      > On Wed, 25 Apr 2001 18:30:58 -0000, perl-beginner@y... wrote:
      >
      > > Is the prompt different on the two machines?
      > > I think the Net::Telnet module looks for a prompt to know when to
      > > issue more commands.
      > >
      > > --- In perl-beginner@y..., Jeremiah Megie <jmegie81@e...> wrote:
      > > > I have some code that tries to telnet to a machine, but it
      doesn't
      > > work. I
      > > > have narrowed it down to where it hangs at. Here is the code:
      > > >
      > > > #!/usr/bin/perl
      > > > use Net::Telnet;
      > > >
      > > > &add_dns9
      > > >
      > > > sub add_dns9
      > > > $host = 'dns9.domain.net';
      > > > $username = 'actualuserid';
      > > > $passwd = 'actualpasswd';
      > > > $t = Net::Telnet->new( Timeout => 10,
      > > > Host => $host,
      > > > Dump_Log => 'dump.log'
      > > > Input_log => 'input.log');
      > > > $t->login($username, $passwd);
      > > > $t->close;
      > > > }
      > > >
      > > >
      > > > It sits there hanging at the password, yet I know it's all
      correct
      > > because I
      > > > can telnet manually and it works fine. Now, here's the kicker.
      > > This
      > > > *exact* code works fine in a different script. The only
      difference
      > > is; it
      > > > is telneting to a different server. So, am I to assume that
      this is
      > > a
      > > > server issue?
      > > >
      > > >
      > > > Jeremiah
      > > >
      > > >
      > > >
      > > >
      > > >
      > > > _______________________________________________________
      > > > Send a cool gift with your E-Card
      > > > http://www.bluemountain.com/giftcenter/
      > >
      >
      >
      > later,
      > J
      > |===============|
      > | My Websites!! |
      > |===============|
      >
      > http://iam.bmezine.com/?keldon
      > http://www.creatyveinsanity.com
      >
      >
      >
      >
      >
      > _______________________________________________________
      > Send a cool gift with your E-Card
      > http://www.bluemountain.com/giftcenter/
    Your message has been successfully submitted and would be delivered to recipients shortly.