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:
- 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.
- You may be referring to the log/dump files specified in the Net::Telnet modules new function. When I look at the documentation, it appears to me that you're handing it the name of a file instead of a file handle. (I've not used the module, so I may be misreading the documentation.
- Also, since you're creating the telnet objects in a loop, each telnet object overwrites the specified log files with a new version. So you'd only get the logs for the last address (unless the files were kept open, in which case you'd only get the first addresses logs.)
(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
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.