use strict; use Net::Telnet; # definitions my $testfilename = "iplist1.txt"; my $dumplog = "dumplog.txt"; my $outputlog = "outputlog.txt"; my $optionlog = "optionlog.txt"; my $inputlog ="inputlog.txt"; our $recordlog ="recordlog.txt"; my $string0 = 'Connected' ; my $string1 = "\015\012" ; my $string2 = '\\CR \\LF' ; # #open (OUT,'>>', "$recordlog"); # iterating file open (IPS, '<', $testfilename) or die('unable to open the file', $testfilename ); while (my $ip = ) { chomp $ip; my $telnett = Net::Telnet->new(Host => "$ip", Port => 'xxxx', Dump_log => "$dumplog", input_log => "$inputlog", option_log => "$optionlog", output_log => "$outputlog", timeout => 10, errmode => (sub { open(OUT, '>>', "$recordlog"); print OUT "Bad connection - Unable to connect to IP $ip at \r\n" ; print OUT "-------------------\r\n"; next;})); $telnett->open("$ip") or die "hai $telnett->errmsg "; # add Errmode and output handle print "connected \n"; $telnett->waitfor('//'); print "carriage return: sending \\CR \\LF \n"; print "carriage return: waiting ...\n"; my $output = $telnett->put(String => $string2, Errmode => 'die', Timeout => '4',); print "The server returned: $output \n"; # Error handling # my $etc0 # expanding IP Networks # my $etc1 # Logging everything # my $etc2 }