finding local IP?
Dar Scott
dsc at swcp.com
Tue Dec 21 13:49:47 EST 2004
On Dec 21, 2004, at 11:20 AM, Ken Ray wrote:
>> MacOS X
>> put replaceText(shell("/sbin/ifconfig en0 | head -3 | grep 'inet
>> '
>> | cut -d' ' -f 2"),"(\s|\(|\))","") into theIPAddress
>
> I'd always used this:
>
> put shell("ipconfig getifaddr en0") into tIPAddress
> if tIPAddress contains "failure" then put "" into tIPAddress
>
> I guess there's more than one way to skin a cat...
Both of these get only the first one IP address associated with en0. I
guess 99.5% of the time that is what you want. I imagine that few Macs
have more than one IP address on en0.
On my system this always gets the initial one, no matter the order in
network setup.
Dar
**********************************************
DSC (Dar Scott Consulting & Dar's Lab)
http://www.swcp.com/dsc/
Programming Services and Software
**********************************************
More information about the use-livecode
mailing list