Page 1 of 1 1
Topic Options
#99383 - 2003-03-09 09:34 AM How to obtain the IP address?
Ryan Dao Offline
Fresh Scripter

Registered: 2003-03-09
Posts: 45
Hi,

I need to be able to determine the default gateway of our users using kixtart. With the default gateway, I can use if/else to install the program from the local server. We have many location and I want to use the script to install a program from the local server by checking the default gateway. For example if the gateway is 10.1.1.1 then install the program from the 10.1.1.21 server and if the gateway is 10.1.2.1 then install the program from 10.1.2.21.

Thanks,

Ryan

Top
#99384 - 2003-03-09 09:43 AM Re: How to obtain the IP address?
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
Hello Ryan and welcome to the board.

Please take a look in the UDF (User Defined Functions) library either here on KiXtart.org or over on the ScriptLogic website.

I'm sure either or both sites have written code for what your trying to do.

UDFs require you to be using KiXtart v4.02 or newer though.

Here are 3 UDFs I find here on KORG that pertain to "Gateway"

http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=12;t=000146

http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=12;t=000148

http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=12;t=000016

[ 09. March 2003, 09:45: Message edited by: NTDOC ]

Top
#99385 - 2003-03-09 09:50 AM Re: How to obtain the IP address?
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear Ryan,

Also welcome to the board.

For fast searching use above mirrors in NTDOC's signature.
It has on the left a Search UDFs link.
Our result for your question was
- EnumIPInfoAll
- GetIPinfo
- CheckNICs
greetings.
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#99386 - 2003-03-09 05:34 PM Re: How to obtain the IP address?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
First of all, there's also the native ENUMIPINFO() function, which retrieves the defaut gateway. Secondly, please read TCP/IP Primer, Part I - IP Addresses in the FAQ Forum.
_________________________
There are two types of vessels, submarines and targets.

Top
#99387 - 2003-03-10 03:28 AM Re: How to obtain the IP address?
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Hey Ryan...

Heres some code you can try out. Im sure some of the above UDF links do close to the same thing but I was bored. Tested it on XP and 98. Would also suggest the built in EnumIPInfo function BUT it has a lot of dependencies (especially doesnt work on NT!).

code:
 
$tempfile = "%temp%\ipinfo.xxx"
$filehandle = FreeFileHandle()
Del $tempfile

If @inwin=2
shell 'winipcfg /batch $tempfile'
Else
shell '%comspec% /c ipconfig > $tempfile'
Endif

If Open ($filehandle, "%temp%\ipinfo.xxx")=0
$line = ReadLine($filehandle)
While @ERROR=0
If Instr ($line, "Default Gateway")
If $DefaultGateway = ""
$DefaultGateway = Trim (SubStr ($line, InStr ($line, ":")+1))
$InstallServer = SubStr ($DefaultGateway, 1, InStrRev ($DefaultGateway, "."))
$InstallServer = $InstallServer+"21"
Else
? "More than one default gateway found...Aborting"
Exit
Endif
Endif
$line = ReadLine($filehandle)
LOOP
$null = Close ($filehandle)
Del $tempfile
? "Default gateway is "+$DefaultGateway
? "App will be run from "+$InstallServer
Else
? "IP Info file could not be opened, error code: "+@ERROR
Endif

get $



[ 10. March 2003, 03:32: Message edited by: CitrixMan ]

Top
#99388 - 2003-03-10 06:40 PM Re: How to obtain the IP address?
Ryan Dao Offline
Fresh Scripter

Registered: 2003-03-09
Posts: 45
Wow. This forum is awesome! Thanks for quick replies. Will try and post result soon.

Thanks again,

Ryan

Top
Page 1 of 1 1


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

Who's Online
0 registered and 1376 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.06 seconds in which 0.028 seconds were spent on a total of 12 queries. Zlib compression enabled.

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