• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: machine IP address
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: machine IP address


  • Subject: Re: machine IP address
  • From: "John C. Welch" <email@hidden>
  • Date: Tue, 25 Jul 2006 16:17:24 -0500
  • Thread-topic: 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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: machine IP address
      • From: Adam Bell <email@hidden>
    • Re: machine IP address
      • From: Stan Cleveland <email@hidden>
References: 
 >machine IP address (From: Bob Cuilla <email@hidden>)

  • Prev by Date: Re: machine IP address
  • Next by Date: Re: machine IP address
  • Previous by thread: Re: machine IP address
  • Next by thread: Re: machine IP address
  • Index(es):
    • Date
    • Thread