newkij1 has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

I am telnetting into a server successfully but the response is very slow. I tried to rename /etc/resolve.conf but no luck. What could be the problem ?
I am using this code to telnet.

NET::Telnet my $obj = Net::Telnet->new(Host => 'X.X.X.X', Timeout => 10, Errmode = +> 'return'); $obj->open('X.X.X.X') or die; $obj->login($username, $password);

Every time I pass a command its gives me an error "timeout error".
Small commands(like passing "ls" via telnet) are working fine but are too slow.

I am using the same script to login into other server and there everything works fine. No issues at all.

Thanks,
NEW USER OF PERL

Replies are listed 'Best First'.
Re: Slow Telnet Response ?????
by hippo (Archbishop) on Jun 04, 2014 at 08:16 UTC
    I am using the same script to login into other server and there everything works fine. No issues at all.

    From this we can conclude that the problem lies not with anything to do with perl but rather with some aspect of the remote server or your network connection to it. This is a task for the administrator of that remote system or the intervening network. Give them a copy of your script, details of all three machines and lots more diagnostic data than you've provided here.

    Good luck.

Re: Slow Telnet Response ?????
by taint (Chaplain) on Jun 04, 2014 at 05:02 UTC

    Well, I had a look at the Net::Telnet Module. After reading just a few lines. It occurred to me that maybe the apparent timeout error, is actually a timeout from a prompt waiting your username, and password. Have you tried the example provided?

    use Net::Telnet (); $t = new Net::Telnet (Timeout => 10, Prompt => '/bash\$ $/'); $t->open($host); $t->login($username, $passwd); @lines = $t->cmd("who"); print @lines;
    Appears to me, you're going to have to respond in some manner to the opposite ends prompt for this information. Depending on what sort of system you're logging into, you may even need to set the shell environment.

    Best wishes.

    --Chris

    ¡λɐp ʇɑəɹ⅁ ɐ əʌɐɥ puɐ ʻꜱdləɥ ꜱᴉɥʇ ədoH

Re: Slow Telnet Response ?????
by hexcoder (Curate) on Jun 04, 2014 at 07:04 UTC
    I understand your description in that way, that the login succeeds and the latency for a given command is high. But the general throughput of the connection is not slow.

    Then I would try to call a binary with its explicit path like /usr/bin/perl -v. If that variant gives a faster response, then have a look at the PATH environment variable to see what is included. Maybe you need to set this for yourself?

Re: Slow Telnet Response ?????
by taint (Chaplain) on Jun 04, 2014 at 03:55 UTC
    Greetings, newkij1.

    Please add the following near the top of your script.

    use strict; use warnings;
    These should always be present in your scripts. What's more, by doing so you'll likely receive answers to your questions, before you even have to ask. Perl is funny that way. :)

    Best wishes.

    --Chris

    ¡λɐp ʇɑəɹ⅁ ɐ əʌɐɥ puɐ ʻꜱdləɥ ꜱᴉɥʇ ədoH