finding local IP?

Thierry Arbellot thierry.arbellot at wanadoo.fr
Tue Dec 21 04:14:45 EST 2004


On Tuesday, Dec 21, 2004, at 09:40 Europe/Paris, kweto wrote:

> Hello All,
>
> Thanks to much kind advise, I can now create stacks that are able to
> interact over my school's LAN. Next step is to simplify my messy 
> scripting
> methods.
>
> Question: Is there a Rev command (or elegant trick?) for retrieving the
> local IP address of the computer on which a stack is running?
>
> For the moment, my half-baked solution is to (1) use the router 
> software to
> assign each computer a permanent IP address, and then (2) store those 
> IP
> addresses as a text file. That way, each time a LAN-based stack opens 
> it
> retrieves its computer's IP address from that text file.
>
> There must be a better way, though!
>
> Cheers,
> Nicolas Cueto
> (Japan)

Hi,

2 tricks for OS X and Win 2K
theIPAddress is the local IP address of the computer

MacOS X
     put replaceText(shell("/sbin/ifconfig en0 | head -3 | grep 'inet ' 
| cut -d' ' -f 2"),"(\s|\(|\))","") into theIPAddress

Windows 2000/XP
     put "255.255.255.255:43222" into testSocket
     open datagram socket to testSocket
     put hostAddress(testSocket) into theIPAddress
     close socket testSocket

Thierry




More information about the use-livecode mailing list