Getting cross-platform IP address

Alex Rice alrice at arcplanning.com
Wed Aug 27 15:15:02 EDT 2003


On Wednesday, August 27, 2003, at 01:38  PM, Rob Gould wrote:

> I must be missing something obvious, but is there a command that 
> provides the user's IP address (whether Mac or PC).

There is hostNameToAddress()

put hostNameToAddress("localhost") -- always 127.0.0.1 on UNIX, the 
loopback interface
put hostNameToAddress("www.runrev.com") -- 64.23.0.192

However there is no 1 genuine IP address for a user's machine. IP 
interfaces can be numerous, aliased, and using different transports 
like ppp, ethernet, etc. For instance a user could have a dialup ppp 
address, plus 2 different ethernet cards installed on their computer. 
All active, with different IPs. An IP address can also change 
frequently in the case of ethernet DHCP or dialup ppp setups.

You could go platform specific and do shell() with command "ifconfig 
-a" on OS X and Unix, and the equivalent on Windows - "winipstat" or 
something like that. You would have to scan the human-readable results 
and decide which is the IP you are interested in.

Sorry I know this doesn't really answer the question. I am speculating 
here that it's not possible to do just in transcript.

Alex Rice, Software Developer
Architectural Research Consultants, Inc.
http://ARCplanning.com




More information about the use-livecode mailing list