Smith has asked for the wisdom of the Perl Monks concerning the following question:
Im using Net::SSH::Perl and Net::Telnet to login to a list of routers. I dont know if the routers are using SSH or Telnet, so I need to try both.
The problem is the script is dying within the SSH module and not going to the next line in my script.
Can anyone tell me how I can get around this?
Heres the portion of my script Im refering to:
$rtrs = "$workdir/bin/wanrtrs"; $outfile = "$workdir/$date-allnetrtrscn.raw"; open ($INR,$rtrs) || die "Can't open the file: $!\n"; open ($OUT,">>$outfile") || die "Can't open the file: $!\n"; while (<$INR>){ chomp(); push(@rtrs, $_); } foreach $host (@rtrs){ $remote = Net::SSH::Perl->new($host); $remote->login($user, $pass); if ( ! $remote ){ print "ERROR: Problem Connecting to $host\n"; $remote = Net::Telnet->new($host); $remote->login($user, $pass); } ($stdout) = $remote->cmd("sh ip vrf int"); print $OUT "$host:sh ip vrf int\n$stdout\n"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How do I stop SSH Module from dieing?
by Fletch (Bishop) on Jan 29, 2007 at 16:09 UTC | |
Re: How do I stop SSH Module from dieing?
by educated_foo (Vicar) on Jan 29, 2007 at 16:15 UTC | |
Re: How do I stop SSH Module from dieing?
by RobPayne (Chaplain) on Jan 29, 2007 at 16:40 UTC | |
by Smith (Initiate) on Jan 29, 2007 at 20:19 UTC |
Back to
Seekers of Perl Wisdom