Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

IP address


1 reply to this topic

Matti Maenpaa

Matti Maenpaa
  • Members
  • 5 posts

Posted 12 November 2001 - 12:36

What is the best way to get the IP address of the host to a variable in installscript?

I know that there can be many IP's assigned to a host, but I'd be glad to get even one of them to a variable (not just 127.0.0.1).

-Matti


Matti Maenpaa

Matti Maenpaa
  • Members
  • 5 posts

Posted 18 November 2001 - 11:31

I solved this using a .cmd file - as this only needs to work on NT/2000/XP, I made a script named getip.cmd conrtaining this:

@echo off
set FILE=%1
if {%1}=={} set FILE=NOFILE
for /f "delims=[] tokens=2" %%i in ('ping -n 1 %COMPUTERNAME% ^| findstr /I "%COMPUTERNAME%"') do set IP=%%i
echo %IP%
if not %FILE%==NOFILE echo %IP% > %FILE%

Then I called this script from InstallScript and directed the output to a file. I opened the file and I got the IP I wanted. Works quite well on multihomed hosts too.

-MM