Telnet to multiple systems, continue on failure

Telnet to multiple systems, continue on failure

am 18.03.2006 01:09:37 von jason.wolford

I'm trying to telnet to multiple system IP address that I'm loading
from a file. However, if one of the telnet connections fails, the
scripts stops. I want it to continue trying to telnet to the rest of
the devices in the list even if connections fail. I'm fairly new at
this and any assistance would be helpful.

while (my $ip = ){


my $telnet = Net::Telnet->new(Host=>"$ip", Port=>'23')
$telnet->login("user","password");
$telnet->print('en');
$telnet->print('password');
$telnet->print("$set_serv_ip");
my @lines = $telnet->print("restart all");
print OUT @lines;


problem connecting to "10.1.2.127
", port 23: Unknown error at C:\server-change.pl line 53

Re: Telnet to multiple systems, continue on failure

am 18.03.2006 01:18:56 von Keith Keller

On 2006-03-18, jason.wolford@gmail.com wrote:
> I'm trying to telnet to multiple system IP address that I'm loading
> from a file. However, if one of the telnet connections fails, the
> scripts stops. I want it to continue trying to telnet to the rest of
> the devices in the list even if connections fail. I'm fairly new at
> this and any assistance would be helpful.

Since you're using Net::Telnet, I assume you want to read those docs for
the errmode method. If that's not what you want, you'll need to post
more specific information to the group.

--keith

--
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom
see X- headers for PGP signature information

Re: Telnet to multiple systems, continue on failure

am 18.03.2006 02:39:05 von Jake Peavy

jason.wolford@gmail.com wrote:

> while (my $ip = ){
>
>
>
> problem connecting to "10.1.2.127
> ", port 23: Unknown error at C:\server-change.pl line 53

you might want to chomp that $ip...

-jp

Re: Telnet to multiple systems, continue on failure

am 29.03.2006 20:56:26 von jason.wolford

Solution:

my $telnet = Net::Telnet->new(Host=>"$data[0]", Port=>'23',
timeout=>4, errmode=>
(sub {
open(OUT, ">>telnet.log");
print "Bad $data[0] - Unable to connect to IP $opt_s at $mytime
(local server time)\r\n";
print "--------------------------------\r\n";
next;}));