#99383 - 2003-03-09 09:34 AM
How to obtain the IP address?
|
Ryan Dao
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
|
|
|
|
#99385 - 2003-03-09 09:50 AM
Re: How to obtain the IP address?
|
MCA
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.
|
|
Top
|
|
|
|
#99387 - 2003-03-10 03:28 AM
Re: How to obtain the IP address?
|
ShaneEP
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
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
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 811 anonymous users online.
|
|
|