finding local IP... on Win98?

Ken Ray kray at sonsothunder.com
Fri Dec 24 21:55:09 EST 2004


On 12/24/04 12:44 AM, "kweto" <nrkweto03 at hotmail.com> wrote:

 
> So I'm back to square one, i.e., how to use Rev to find out a computer's LAN
> IP.

How about doing a shell to "ipConfig /all" and then parsing the result? On
my Windows 98 machine I get two IP Addresses, one in a block that says "0
Ethernet adapter" and one that says "1 Ethernet adapter". I have a chunk of
code that I've used to find the MAC address, so I adapted it to get the IP
address. Since there's more than one, I continue to search until I get
something other than 0.0.0.0 (watch for word wraps):

on mouseUp
  put GetMyIP() into tIP
  if tIP contains "Error" then
    answer tIP
  else
    -- do what you want with the IP address
  end if
end mouseUp

function GetMyIP
  local tStart,tEnd
  put specialFolderPath("system") & "/IPCONFIG.EXE" into tWinIPConfig
  put specialFolderPath("system") & \
    "/SYSTEM32/IPCONFIG.EXE" into tWinSysIPConfig
  put (there is a file tWinIPConfig) into winExists
  put (there is a file tWinSysIPConfig) into sys32Exists
  if winExists or sys32Exists then
    set the hideConsoleWindows to true
    put shell("ipconfig /all") into tData
    repeat
      if matchChunk(tData,"IP Address[\. ]*: ([A-Z0-9\.]*)",tStart,tEnd)
then
        put char tStart to tEnd of tData into tIP
        if tIP <> "0.0.0.0" then
          return tIP
        else
          delete char 1 to tEnd of tData
        end if
      else
        return "Error: IP Address not found."
      end if
    end repeat
    return "Error: IP Address not found."
  else
    return "IPCONFIG not found"
  end if
end GetMyIP

HTH,

Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com




More information about the use-livecode mailing list