Re: How to check an IP Address
Re: How to check an IP Address
- Subject: Re: How to check an IP Address
- From: Jon Pugh <email@hidden>
- Date: Wed, 22 Jul 2009 14:29:10 -0700
At 4:12 PM -0500 7/22/09, Andrew P wrote:
>I want to check the current IP Address on my computer, then display it in a dialog.
Well, there's an IP address that your computer has, which may be behind a NAT or some other server, and there's the router address which is what the rest of the Internet sees you as.
This script shows either. I got it from someone on this list and saved it.
Jon
global ip_
global buttonPressed
global ipChosen
set ipList to {"Internal", "External"}
set temp to (choose from list ipList with prompt "Which IP would you like?" without multiple selections allowed and empty selection allowed) as text
set ipChosen to text of temp
if ipChosen is "External" then
set AppleScript's text item delimiters to ":"
set ip_ to word 1 of text item 2 of (do shell script "curl http://checkip.dyndns.org/")
my displayDialog()
else
if ipChosen is "Internal" then
set ip_ to do shell script "/sbin/ifconfig en0 | grep 'inet ' | awk '{print $2}'"
if ip_ = "" then
set ip_ to do shell script "/sbin/ifconfig en1 | grep 'inet ' | awk '{print $2}'"
end if
my displayDialog()
else
return
end if
end if
on displayDialog()
display dialog "Your " & ipChosen & " IP is " default answer ip_
end displayDialog
_______________________________________________
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