Seite 1 von 1

[Solved] Function IP address

Verfasst: 26 Dez 2013, 16:48
von nirale33
HI Everyone,

I want to create an installation rule based on the IP address of the machine for put a different CD key for each society.

Is there a method to retrieve the IP in a variable so you can call after?

Thx

Regards,

Re: Function IP address

Verfasst: 29 Dez 2013, 16:54
von d.oertel
HI,

opsi-winst knows the constant
%IPAddress%
and the Functions:
getMyIpByTarget
and
GetIpByName

Often is this the best way:

Code: Alles auswählen

set $CompValue$ = getMyIpByTarget("%opsiServer%")
gives you the IP of the Interface that is used to communicate with the opsi server.

see:
download.uib.de/opsi_stable/doc/html/en ... anual.html

regards

d.oertel

Re: Function IP address

Verfasst: 30 Jan 2014, 16:50
von nirale33
Thx for your reply

I'm almost there, but I've a problème, I want "cut" my IP for select only the second byte.

There are many subnet (10.78.*.* , 10.80.*.* ...) and one licence key for each subnet.

IP client : 10.78.1.5
I want to compare the second byte with some I've already filled at the beginning of my script.

My script is :

Code: Alles auswählen

[Actions]

Message "F-Secure setup"
SetLogLevel=6

DefVar $IPAddress$
DefVar $IPpart$
DefVar $Ent1$
DefVar $IPtotal$

Set $IPtotal$=$IPAddress$
[color=#FF0000]Set $IPpart$=getSubList(3: 2, $IPtotal$)[/color]
Set $Ent1$="87"

if ($IPpart$ =$Ent1$)
	sub_install
else
	stop "Failled"
endif

The red part returns an error

Re: Function IP address

Verfasst: 31 Jan 2014, 14:28
von nirale33
Yeah it works with this script.

Now I can attribute an CD key for each society :D

Code: Alles auswählen

[Actions]

Message "F-Secure setup"
SetLogLevel=6


DefVar $CompValue$
DefVar $Ent1$

set $CompValue$=getMyIpByTarget("%opsiServer%") > Find the computer IP address
Set $Ent1$="87" > We are in A class IP (10.87.*.*)

if contains($CompValue$, $Ent1$) > Find if in my IP there is the number 87
	
	sub_install
else
	stop "Failled"
endif