Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: machine IP address



Title: Re: machine IP address
On 7/25/06 13:47, "Bob Cuilla" <email@hidden> wrote:

> Does anyone know a good way to get the IP address?

Well, in addition to the others listed, you can use networksetup in
/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Support

networksetup -listallnetworkservices gets you the list of services in your current config. From the help section: Display list of services. An asterisk (*) denotes that a network service is disabled.

Then it's just a matter of using the -getinfo switch:

networksetup -getinfo AirPort

networksetup -getinfo "Built-in Ethernet"

this script:

property theServiceInfo : "/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Support/networksetup -getinfo "

set theServiceList to do shell script "/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Support/networksetup -listallnetworkservices"
set theServiceList to every paragraph of theServiceList
set theServiceList to the rest of theServiceList --the first item is the explanatory text about the asterisk, and we don't need it
set theEnabledServices to {}
set theIPAddressList to {}

repeat with x in theServiceList --get a list of enabled services
   if the first character of x is not "*" then
       set the end of theEnabledServices to contents of x
   end if
end
repeat


set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {" "}
try
   repeat with x in theEnabledServices
       set theIPAddress to do shell script theServiceInfo & (quoted form of the contents of x) & "|/usr/bin/grep \"IP address\""
        
set theIPAddress to every text item of theIPAddress
       set the end of theIPAddressList to (contents of x) & ": " & (last text item of theIPAddress)
    
end repeat
end
try
set
AppleScript's text item delimiters to oldDelims

should get you most of the way there.

--
"Death waits in the dark."
US Army Task Force 160 "Night Stalkers"
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-users/email@hidden

This email sent to email@hidden

References: 
 >machine IP address (From: Bob Cuilla <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.