keep getting time out on Net::Telnet->cmd in my perl script

Discussion in 'Perl Misc' started by Vic, Sep 9, 2009.

  1. Vic

    Vic Guest

    I've a perl script which tries to telnet into a server and then
    execute a few command
    Here is my code

    sub AgaBringDown {
    my ($GVHOME,$Server) = @_;
    my $string;
    my @lines;

    ### Seting up the GVHOME
    #$ENV{'GVHOME'} = $GVHOME;
    my $username = 'vpatanka';
    my $passwd = 'gen2boyS2';
    my $t = new Net::Telnet (Timeout => 10, Prompt => '/login: $/i');
    $t->open("$Server");
    $t->waitfor('/login: $/i');
    $t->print($username);
    $t->waitfor('/password: $/i');
    $t->print($passwd);

    $string = "setenv GVHOME $GVHOME";
    my $temp = $t->cmd($string);
    }

    As I mentioned I keep getting error on the last line
    command timed-out at ConfigurationSetup.pl line 270
    at /usr/local/geneva/perl/lib/site_perl/5.8.8/Net/Telnet.pm line 2036
    Net::Telnet::_croak('Net::Telnet=GLOB(0x879538)', 'command
    timed-out') called at /usr/local/geneva/perl/lib/site_perl/5.8.8/Net/
    Telnet.pm line 539
    Net::Telnet::error('Net::Telnet=GLOB(0x879538)', 'command
    timed-out') called at /usr/local/geneva/perl/lib/site_perl/5.8.8/Net/
    Telnet.pm line 361
    Net::Telnet::cmd('Net::Telnet=GLOB(0x879538)', 'setenv GVHOME /
    home/vpatanka/800currentSAGAV2_P') called at ConfigurationSetup.pl
    line 270
    main::AgaBringDown('/home/vpatanka/800currentSAGAV2_P',
    'nemo') called at ConfigurationSetup.pl line 190
    main::SetupConfig() called at ConfigurationSetup.pl line 123
    main::SetupData() called at ConfigurationSetup.pl line 29

    If I login manually in telnet with the same steps it works fine.
    Please help. thanks
     
    Vic, Sep 9, 2009
    #1
    1. Advertisements

  2. Vic

    Vic Guest

    On Sep 9, 1:18 pm, Vic <> wrote:
    > I've a perl script which tries to telnet into a server and then
    > execute a few command
    > Here is my code
    >
    > sub AgaBringDown {
    >     my ($GVHOME,$Server) = @_;
    >     my $string;
    >     my @lines;
    >
    >     ### Seting  up the GVHOME
    >     #$ENV{'GVHOME'}  = $GVHOME;
    >     my $username = 'vpatanka';
    >     my $passwd = 'gen2boyS2';
    >     my $t = new Net::Telnet (Timeout => 10, Prompt => '/login: $/i');
    >     $t->open("$Server");
    >     $t->waitfor('/login: $/i');
    >     $t->print($username);
    >     $t->waitfor('/password: $/i');
    >     $t->print($passwd);
    >
    >      $string = "setenv GVHOME $GVHOME";
    >       my $temp = $t->cmd($string);
    >
    > }
    >
    > As I mentioned I keep getting error on the last line
    > command timed-out at ConfigurationSetup.pl line 270
    >  at /usr/local/geneva/perl/lib/site_perl/5.8.8/Net/Telnet.pm line 2036
    >         Net::Telnet::_croak('Net::Telnet=GLOB(0x879538)', 'command
    > timed-out') called at /usr/local/geneva/perl/lib/site_perl/5.8.8/Net/
    > Telnet.pm line 539
    >         Net::Telnet::error('Net::Telnet=GLOB(0x879538)', 'command
    > timed-out') called at /usr/local/geneva/perl/lib/site_perl/5.8.8/Net/
    > Telnet.pm line 361
    >         Net::Telnet::cmd('Net::Telnet=GLOB(0x879538)', 'setenv GVHOME /
    > home/vpatanka/800currentSAGAV2_P') called at ConfigurationSetup.pl
    > line 270
    >         main::AgaBringDown('/home/vpatanka/800currentSAGAV2_P',
    > 'nemo') called at ConfigurationSetup.pl line 190
    >         main::SetupConfig() called at ConfigurationSetup.pl line 123
    >         main::SetupData() called at ConfigurationSetup.pl line 29
    >
    > If I login manually in telnet with the same steps it works fine.
    > Please help. thanks


    There was an issue with the prompt at the remote host. I got it fixed.
    Thanks
     
    Vic, Sep 10, 2009
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dpackwood
    Replies:
    3
    Views:
    2,190
  2. Achim Domma (Procoders)

    read input for cmd.Cmd from file

    Achim Domma (Procoders), Jun 3, 2005, in forum: Python
    Replies:
    2
    Views:
    8,394
    Peter Otten
    Jun 3, 2005
  3. Sarir Khamsi

    Interpreter-like help in cmd.Cmd

    Sarir Khamsi, Jun 9, 2005, in forum: Python
    Replies:
    4
    Views:
    587
    Bengt Richter
    Jun 26, 2005
  4. =?ISO-8859-1?Q?Sch=FCle_Daniel?=

    [exec cmd for cmd in cmds]

    =?ISO-8859-1?Q?Sch=FCle_Daniel?=, Mar 8, 2006, in forum: Python
    Replies:
    3
    Views:
    626
    Scott David Daniels
    Mar 8, 2006
  5. Carcarius
    Replies:
    0
    Views:
    491
    Carcarius
    Dec 6, 2007
  6. born in USSR

    Net:Telnet cmd() stop performance

    born in USSR, Sep 15, 2009, in forum: Ruby
    Replies:
    1
    Views:
    263
    born in USSR
    Sep 16, 2009
  7. justme

    returning from Net::Telnet cmd

    justme, Oct 29, 2004, in forum: Perl Misc
    Replies:
    0
    Views:
    176
    justme
    Oct 29, 2004
  8. Replies:
    15
    Views:
    1,734
Loading...