Click here to get back home

Telnet to multiple systems, continue on failure

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Telnet to multiple systems, continue on failure jason.wolford 03-17-2006
Posted by jason.wolford on March 17, 2006, 7:09 pm
Please log in for more thread options


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 = <FILE>){


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


Posted by Keith Keller on March 17, 2006, 7:18 pm
Please log in for more thread options


> 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


Posted by DJ Stunks on March 17, 2006, 8:39 pm
Please log in for more thread options



jason.wolford@gmail.com wrote:

> while (my $ip = <FILE>){
>
> <snip>
>
> 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


Posted by jason.wolford on March 29, 2006, 1:56 pm
Please log in for more thread options


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;}));


Similar ThreadsPosted
Telnet to multiple systems, continue on failure March 17, 2006, 7:10 pm
How do you telnet from 1 host to another using Telnet Module December 21, 2005, 4:15 pm
net::telnet to ms telnet server May 19, 2005, 12:28 am
Storing multiple cookies June 9, 2007, 11:58 am
GD make test failure January 16, 2005, 5:11 pm
lookfor failure in SerialPort November 30, 2005, 4:56 pm
AppConfig failure with ARGCOUNT_LIST May 22, 2007, 10:33 am
Sudo.pm test failure April 4, 2008, 2:37 pm
WWW::Mechanize module: multiple Select. July 13, 2004, 7:36 pm
multiple packages (modules) in the same file May 2, 2005, 3:53 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap