Morgon:

Your advice was good, it helped the code to run without error, that is good. Now since its running i can see the next issue --the successful output isn't going to "telnet.log" . I am still looking at the documentation to check what went wrong and where i need to change.

Here is the changes i made

#! /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 = <IPS>) { chomp $ip; #ping($_) ; #print "$_ " ; my $telnet = Net::Telnet->new(Host=>"$ip", Port=>'xxx', timeout=>4, er +rmode=> (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 ;

In reply to Re^2: Telnet list of IP and get information stored to a file by sanju7
in thread Telnet list of IP and get information stored to a file by sanju7

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.