Page 1 of 1 1
Topic Options
#207727 - 2013-09-12 05:40 PM Am I using GetIpOptions correct?
jonneeklund Offline
Fresh Scripter

Registered: 2005-04-12
Posts: 5
Loc: SWE
Hi,

Complex network with a lot of branch-offices on different IP-subnets. I need to set a variable to a specific server on the subnet where the client is located.

The script is pausing when I do
 Code:
Dim $SubnetArray[3]
$SubnetArray = Split(getipoptions("DefaultGW"), ".", -1)
for $i = 0 to 3
  $SubnetArray[$i] = Val($SubnetArray[$i])
next
$DBA = "\\" + $SubnetArray[0] + "." + $SubnetArray[1] + "." + $SubnetArray[2] + "." + "27"
$APP = "" + $SubnetArray[0] + "." + $SubnetArray[1] + "." + $SubnetArray[2] + "." + "2"


I am calling the getipoptions.udf earlier in the script.

Am I doing something wrong with GetIpOptions or is it just slow?

TIA!

Top
#207728 - 2013-09-12 06:23 PM Re: Am I using GetIpOptions correct? [Re: jonneeklund]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
More than likely there is more than 1 network adapter, resulting in the last one's settings being returned, which are probably blank. Have you tried the built in EnumIPInfo()? Give the below code a shot and see if it works on your environment.

 Code:
Do
   $Subnet = EnumIPInfo($x,3,1)
   $x = 1+$x
Until Len($Subnet)

$SubnetArray = Split($Subnet, ".")

for $i = 0 to UBound($SubnetArray)
  $SubnetArray[$i] = Val($SubnetArray[$i])
next
$DBA = "\\" + $SubnetArray[0] + "." + $SubnetArray[1] + "." + $SubnetArray[2] + "." + "27"
$APP = "" + $SubnetArray[0] + "." + $SubnetArray[1] + "." + $SubnetArray[2] + "." + "2"

? $DBA
? $APP
? "DONE"

get $

Top
#207774 - 2013-09-18 04:38 PM Re: Am I using GetIpOptions correct? [Re: ShaneEP]
jonneeklund Offline
Fresh Scripter

Registered: 2005-04-12
Posts: 5
Loc: SWE
Hi, thanks for the suggestion and sorry for my late answer. I somehow forgot to click Watched Topics...

I think I tried EnumIPinfo() and discarded it because of issues with multiple adapters. GetIpOptions() does return the correct IP's, it just takes forever to do it.

Could you walk me through your code? When things get complicated I am not that fluent in Kix. \:\)

Top
#207779 - 2013-09-18 07:34 PM Re: Am I using GetIpOptions correct? [Re: jonneeklund]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Do
$Subnet = EnumIPInfo($x,3,1)
$x = 1+$x
Until Len($Subnet)

It simply does a Do Until loop, that does the EnumIPInfo() everytime it runs until the $Subnet variable contains data. Since you don't know which adapter it is that actually contains the info you want, it starts at 0, and increments by one every loop.

The rest of the code is pretty much what you already had, except for displaying them using the ?'s at the end.

Top
#207792 - 2013-09-19 05:41 PM Re: Am I using GetIpOptions correct? [Re: ShaneEP]
jonneeklund Offline
Fresh Scripter

Registered: 2005-04-12
Posts: 5
Loc: SWE
Thanks!

Ok, now I remember why I didn't use EnumIPinfo(). I think it found the BT-adapter or something like that on some notebooks and that screwed things up.

Actually my script now runs at regular speed again. Don't know why, but something healed itself...

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Henriques) and 2516 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.218 seconds in which 0.121 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org