Sign in to follow this  
Followers 0
Sander Timmerman

Calculate ip range

10 posts in this topic

Hi,

I wanted to make a mass ip pinger.

However I can't make up a code that calculates the correct ip range e.g.

$ip1 = 192.168.1.1

To

$ip2 = 192.168.5.1

How can I put all the ip addresses in that range on to an array?!

Thanks in advance!

(I'am dutch bla bla you know ;-))

Share this post


Link to post
Share on other sites



Look at StringSplit.

And then? I really don't have any clue how to do it...

Would someone please post a code he or she already maked, that's the best way I can learn it :whistle:

Thanks!

Share this post


Link to post
Share on other sites

replace the Consolewrite with Ping and whatever else you need there:

$ip1 = "192.168.1.1"
$ip2 = "192.168.5.1"
$range1 = StringSplit($ip1, ".")
$range2 = StringSplit($ip2, ".")
For $OCt1 = $range1[1] To $range2[1]
    $oct2End=$range2[2]
    If $OCt1 < $range2[1] then $oct2End= 254
    For $OCt2 = $range1[2] To $oct2End
        $oct3End=$range2[3]
        If $OCt2 < $range2[2] then $oct3End= 254
        For $OCt3 = $range1[3] To $oct3End
            $oct4End=$range2[4]
            If $OCt3 < $range2[3] then $oct4End= 254
            For $OCt4 = $range1[4] To $oct4End
                ConsoleWrite("Ip:" & $OCt1 & '.' & $OCt2 & '.' & $OCt3 & '.' & $OCt4 & @lf)
            Next
        Next
    Next
Next

:whistle:


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

replace the Consolewrite with Ping and whatever else you need there:

$ip1 = "192.168.1.1"
$ip2 = "192.168.5.1"
$range1 = StringSplit($ip1, ".")
$range2 = StringSplit($ip2, ".")
For $OCt1 = $range1[1] To $range2[1]
    $oct2End=$range2[2]
    If $OCt1 < $range2[1] then $oct2End= 254
    For $OCt2 = $range1[2] To $oct2End
        $oct3End=$range2[3]
        If $OCt2 < $range2[2] then $oct3End= 254
        For $OCt3 = $range1[3] To $oct3End
            $oct4End=$range2[4]
            If $OCt3 < $range2[3] then $oct4End= 254
            For $OCt4 = $range1[4] To $oct4End
                ConsoleWrite("Ip:" & $OCt1 & '.' & $OCt2 & '.' & $OCt3 & '.' & $OCt4 & @lf)
            Next
        Next
    Next
Next

:lmao:

Thank you very very very much!

Exactly what I was looking for! :whistle:

Share this post


Link to post
Share on other sites

Thank you very very very much!

Exactly what I was looking for! :D

I'm a bit new, and was wondering was this the entire script? TIA.

Share this post


Link to post
Share on other sites

Entire script? I'm sure there was more.

Share this post


Link to post
Share on other sites

I'm a bit new, and was wondering was this the entire script? TIA.

Sure..

Entire script? I'm sure there was more.

What is missing in your opinion?

Jos :D


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

The pinging part, gathering the results and outputting those results somehow.

Share this post


Link to post
Share on other sites

The pinging part, gathering the results and outputting those results somehow.

Hi,

Jos said everything........

replace the Consolewrite with Ping and whatever else you need there

So look in helpfile for return from ping and you can code what you want....

;-))

Stefan

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0