#! /usr/bin/perl -w # run telnet to port xxx # read data use strict; use diagnostics; use Net::Telnet; my $file = 'iplist1.txt' ; #my $command = `/bin/ping` ; open (OUT,'>', "telnet.log"); open (IPS, '<', $file) or die('unable to open the file', $file ); while (my $ip = ) { chomp $ip; #ping($_) ; #print "$_ " ; my $telnet = Net::Telnet->new(Host=>"$ip", Port=>'xxx', timeout=>4, errmode=> (sub { open(OUT, ">>telnet.log"); print "Bad connection - Unable to connect to IP $ip at \r\n" ; print "-------------------\r\n"; next;})); } close OUT ; close IPS ;