# Calculate ip range

## Recommended Posts

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?!

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

##### Share on other sites

Look at StringSplit.

##### 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

Thanks!

##### 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```

Live for the present,
Dream of the future,
Learn from the past.

##### 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```

Thank you very very very much!

Exactly what I was looking for!

##### Share on other sites

Thank you very very very much!

Exactly what I was looking for!

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

##### Share on other sites

Entire script? I'm sure there was more.

##### 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

Live for the present,
Dream of the future,
Learn from the past.

##### Share on other sites

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

##### 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

## Create an account

Register a new account

×

• Wiki

• Back

• Git