Jump to content
Sign in to follow this  
jslegers

Checking on IP address Range

Recommended Posts

jslegers

Hello,

I want to make a script that could check on ip address and then perform a installation.

Before I begin I want to know if this is possible.

I want some thing like :

If ip address is in range 10.10.10.1 to 10.10.10.255 than execute program a

If ip address is in range 10.10.20.1 to 10.10.20.255 than execute program b

Is this possible?

Share this post


Link to post
Share on other sites
99ojo

Hi,

one solution:

; keep in mind you might have more ipadresses defined on pc, look at @ipadress macro
;Split 1st Ip Adress into octets, don't return amount into 1 st element of array
$ipokt = StringSplit (@IPAddress1, ".", 2)
;check 3. rd octet
If Number ($ipokt [2]) < 20 Then
    ; execute program a
Else
    ;execute program b
EndIf

;-))

Stefan

Share this post


Link to post
Share on other sites
Steveiwonder

I'm not gonna write the whole script for you, you can work out the rest.

If you have something already then post it here.

$IpAddress = @IPAddress1

$IpAddressSplit = StringSplit($IpAddress, ".", 2)

If $IpAddressSplit[2] = "10" Then

Edit: someone else wrote it for you :mellow:

Edited by Steveiwonder

They call me MrRegExpMan

Share this post


Link to post
Share on other sites
jslegers

I'm not gonna write the whole script for you, you can work out the rest.

If you have something already then post it here.

$IpAddress = @IPAddress1

$IpAddressSplit = StringSplit($IpAddress, ".", 2)

If $IpAddressSplit[2] = "10" Then

Edit: someone else wrote it for you :mellow:

Thanks for the replies it works.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.