Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Login WAIT in Net::SSH::Expect

Status
Not open for further replies.
Oct 27, 2002
21
0
0
US
Greetings all,
I found a script that works to SSH Version 2 into my Cisco Routers but the problem I am having with it is that it oftentimes gives a timed out error and I am not sure how to avoid that, so was hoping someone might have a solution

Code:
#!/usr/bin/perl

use Net::SSH::Expect;

my $ssh = Net::SSH::Expect->new (
            host => "routername",
            password=> 'password',
            user => 'uesrname',
            raw_pty => 1
        );
my $login_output = $ssh->login();
        if ($login_output !~ /rtr-/) {
            die "Login has failed. Login output was $login_output";
        }
#$ssh->exec("stty raw -echo");
$output1=$ssh->exec("show etherchannel summary | inc (s)");
print $output1;
print "\n";


Correct Results:
Code:
[server@myserver]# perl ether.cgi
show etherchannel summary | inc (s)
Flags:  D - down        P - bundled in port-channel
        I - stand-alone s - suspended
        H - Hot-standby (LACP only)
        U - in use      f - failed to allocate aggregator
        M - not in use, minimum links not met
        u - unsuitable for bundling
Number of channel-groups in use: 3
Number of aggregators:           3
Group  Port-channel  Protocol    Ports
routername-rtr-2>

Error Message I get often:

Code:
[server@myserver]# perl ether.cgi
SSHAuthenticationError Login timed out. The input stream currently has the contents bellow:

********************************************************************
* Access to this system is limited to authorized users for company *
* business purposes only.                                          *
*                                                          r040315 *
********************************************************************

username@routername's password:  at /usr/local/lib/perl5/site_perl/5.8.8/Expect.pm line 828

Any assistance with a wait or maybe even a check and relog would be greatly appreciated

TIA

Wally
 
Hi WaltSteadman,

Where did you add the timeout? I'm having the exact same issue and adding timeout options hasn't fixed it for me.

If you could let me know exactly what timeout option fixed it for you it would be much appreciated.

Thanks!
 
ngibsonn, I was just wrestling with the same thing, this worked for me:

my $ssh = Net::SSH::Expect->new (
host => $HOST,
password => $PASS,
user => $USER,
raw_pty => 1,
timeout => 10
);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top