• 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: question regarding IP address from ipconfig
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: question regarding IP address from ipconfig


  • Subject: Re: question regarding IP address from ipconfig
  • From: Steve Thompson <email@hidden>
  • Date: Tue, 21 Aug 2012 20:32:06 +0100

This is how I do it

set my_ips to every paragraph of (do shell script "ifconfig | awk '/inet/ {print $2}' | grep -v :")
Result:
{"127.0.0.1", "192.168.1.227"}

The | grep -v : filters out the IP6 addresses.

set my_ips to every paragraph of (do shell script "ifconfig | awk '/inet/ {print $2}'")
Result:
{"fe80::1%lo0", "127.0.0.1", "::1", "fe80::9227:e4ff:fefd:e7b3%en1", "192.168.1.227"}

Steve
-------------------------
http://about.me/stetho


On 21 Aug 2012, at 19:38, Jim Weisbin <email@hidden> wrote:

> I have a script (actually it's a Filemaker script, but I've listed an un-escaped version here) which gets your internal IP address from ipconfig. Recently I found I had to add "en2" for computers which use a thunderbolt to ethernet adapter. I'm just wondering if this is the best way to do this, or can someone suggest a more elegant, simpler method:
>
> tell application "Finder"
> 	set internalIP to ""
> 	try
> 		set internalIP to do shell script "ipconfig getifaddr en0"
> 	on error
> 		try
> 			set internalIP to do shell script "ipconfig getifaddr en1"
> 		on error
> 			try
> 				set internalIP to do shell script "ipconfig getifaddr en2"
> 			on error
> 				set internalIP to "not found"
> 			end try
> 		end try
> 	end try
> 	display dialog internalIP
> end tell
>
> Any help would be appreciated.
>
> --- Jim Weisbin, C.T.O.
> Human Music and Sound Design
> www.humanworldwide.com
>
>
>
>
>
>
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> AppleScript-Users mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> Archives: http://lists.apple.com/archives/applescript-users
>
> This email sent to email@hidden

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >question regarding IP address from ipconfig (From: Jim Weisbin <email@hidden>)

  • Prev by Date: Re: Is there a way to access the Arrange By:
  • Next by Date: Re: question regarding IP address from ipconfig
  • Previous by thread: question regarding IP address from ipconfig
  • Next by thread: Re: question regarding IP address from ipconfig
  • Index(es):
    • Date
    • Thread