Jump to content

Recommended Posts

Posted

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 ;-))

  • Developers
Posted

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.
  :)

Posted

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:

  • 2 years later...
Posted

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

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
×
×
  • Create New...