Jump to content

Calculate ip range


Recommended Posts

  • Developers

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:

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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:

Link to comment
Share on other sites

  • 2 years later...
  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...