in reply to Re^4: Telnet list of IP and get information stored to a file
in thread Telnet list of IP and get information stored to a file

sanju7:

(a) The code for some reason doesn't logs the message when its success. When tested with a single IP its logging successfully though.

You're not being very specific on *which* log isn't updated. Looking at your code, I can think of several possibilities:

(b) I am not getting how to expand an ip address which is a network (eg:10.3.3.0/24).

There are lots of ways to do it. For the example you give, 10.3.3.0/24, the first 24 bits of the address should remain a constant: 10.3.3, and you should vary the last eight bits through the values 1..255. So first you need to detect that your address needs to be expanded, then figure out which part(s) of the address need to vary, and then generate the appropriate sequence. So the code that does the work on an IP address should be in a subroutine. Then you can call it in a loop for each address in the expansion.

I get the feeling that you're trying to bite off too much at a time. You might consider breaking your project into distinct chunks, and solve each chunk individually.

...roboticus

Replies are listed 'Best First'.
Re^6: Telnet list of IP and get information stored to a file
by sanju7 (Acolyte) on Jul 30, 2010 at 16:52 UTC

    Roboticus

    You may be referring to the print "connected" message, in which case you're not telling it to go to a log file, like you are for the failures.

    Indeed i am referring that, more preciously I need to record this as below like a success message, because telnet gives this why the script cann't get this ?

    dds_pc: _ms=nodecc.dom.org.localþ_si=Process controllerþ_mid=9016þ_sev +=0þ_dt=2010/07/29þ_tm=01:12:02þ_pkg=þ

    but instead the only reply i am getting is ("The server returned: 1") ,

    The server returned: 1

    The server returned: 1

    The server returned: 1

    Bad connection - Unable to connect to IP 3.xx.yy.zz at -------------------

    Bad connection - Unable to connect to IP 3.xxx.yyy.zz at -------------------

    Bad connection - Unable to connect to IP 3.xxx.yyy.y at --------------------

      but instead the only reply i am getting is ("The server returned: 1")

      That's because you're using the $telnet->put method which returns 1 on success. I think you want my @output = $telnet->cmd which will give you the output from the server.