Re: Wan IP Retrieval No Longer Works For Me Under OS X 10.11
Re: Wan IP Retrieval No Longer Works For Me Under OS X 10.11
- Subject: Re: Wan IP Retrieval No Longer Works For Me Under OS X 10.11
- From: Russell Richardson <email@hidden>
- Date: Thu, 29 Oct 2015 11:56:23 -0500
- X_v_e_cd: 9fef280b8a8e9a002001b58dffa16b03
- X_v_r_cd: e35d6f08cccd8654d26aacf7929e1002
Use this...Let me know if that did it.
#Check Internet Connection
#Tell the user we are checking internet
say "Checking your connection to the internet, please wait..."
#Check internet code
set testIP to chkUP("http://www.apple.com")
if testIP then
display dialog "Internet Connection is UP"
else
display dialog "Internet Connection is DOWN"
end if
to chkUP(theURL)
return (count (get ((theURL as URL)'s host & {dotted decimal
form:""})'s dotted decimal form)) > 0
end chkUP
#Script Begin
display alert "What would you like to do" message "Select a network
option" buttons {"RetrieveYourIP", "PingIPOrDomainName", "Quit"}
cancel button "Quit"
set the button_pressed to the button returned of the result
#Buttons
if the button_pressed is "RetrieveYourIP" then
say "Retrieving Your IP address, this may take a moment." without
waiting until completion
WanIP()
display alert "Your IP Address is " & WanIP() & " And has been copied
to your clipboard."
set the clipboard to WanIP()
else if the button_pressed is "PingIPOrDomainName" then
set IP_address to ""
set dialog_1 to display dialog "Enter IP Address or domain name:"
default answer "" with title "Ping IP Address or domain" buttons
{"OK"} default button 1
set the IP_address to the text returned of dialog_1
try
do shell script ("ping -c 2 " & IP_address)
display dialog "Host is up" buttons {"OK"} default button 1 with title
"Host Status"
on error
display dialog "Host unreachable" buttons {"OK"} default button 1 with
title "Host Status"
end try
end if
on WanIP()
set WIP to missing value
set siteList to {"http://checkip.dyndns.org/",
"http://whatismyip.com", "http://www.whatismyipaddress.com",
"http://ipid.shat.net/", "http://www.edpsciences.comhtbin/ipaddress",
"http://www.showmyip.com/"}
repeat with thissite in siteList
try
set WIP to item 1 of paragraphs of (do shell script "curl " & thissite
& " | tr -cs '[0-9\\.]' '\\012' | awk -F'.' 'NF==4 && $1>0 && $1<256
&& $2<256 && $3<256 && $4<256 && !/\\.\\./'")
if WIP is not missing value then exit repeat
end try
end repeat
return WIP
end WanIP
On Wed, Oct 28, 2015 at 11:21 AM, <email@hidden> wrote:
> Hi,
> I updated to Mac OS X El Capitan, and part of my network utilities
> script does not work.
> If a user asks to retrieve their Wan IP, the script no longer does so.
> I've changed no code, the only thing I did do is add some code to
> insure the user's internet is working, but even with that, it should
> not have effected it.
> Are there newer routines I need to use for Wan IP retrieval in OS X El Capitan?
> Here's what I've got.
> #Check Internet Connection
> #Tell the user we are checking internet
> say "Checking your connection to the internet, please wait..."
> #Check internet code
> set testIP to chkUP("http://www.apple.com") or chkUP("http://www.google.com")
> if testIP then
> display dialog "Internet Connection is UP" buttons {"OK"} default
> button 1 with title "Connection Check"
> else
> display dialog "Internet Connection is DOWN" buttons {"Quit"} default
> button 1 with icon stop with title "Connection Error"
> quit
> end if
> to chkUP(theURL)
> return (count (get ((theURL as URL)'s host & {dotted decimal
> form:""})'s dotted decimal form)) > 0
> end chkUP
> #Script Begin
> display alert "What would you like to do" message "Select a network
> option" buttons {"Retrieve Your IP", "PingIPOrDomainName", "Quit"}
> cancel button "Quit"
> set the button_pressed to the button returned of the result
> #Buttons
> if the button_pressed is "RetrieveYourIP" then
> say "Retrieving Your IP address, this may take a moment." without
> waiting until completion
> WanIP()
> display alert "Your IP Address is" & WanIP() & "And has been copied
> to your clipboard."
> set the clipboard to WanIP()
> else if the button_pressed is "PingIPOrDomainName" then
> set IP_address to ""
> set dialog_1 to display dialog "Enter IP Address or domain name:"
> default answer "" with title "Ping IP Address or domain" buttons
> {"OK"} default button 1
> set the IP_address to the text returned of dialog_1
> try
> do shell script ("ping -c 2 " & IP_address)
> display dialog "Host is up" buttons {"OK"} default button 1 with
> title "Host Status"
> on error
> display dialog "Host unreachable" buttons {"OK"} default button 1
> with title "Host Status"
> end try
> end if
> #IP definitions
> on WanIP()
> set WIP to missing value
> set siteList to {"http://checkip.dyndns.org/",
> "http://whatismyip.com", "http://www.whatismyipaddress.com",
> "http://ipid.shat.net/", "http://www.edpsciences.comhtbin/ipaddress",
> "http://www.showmyip.com/"}
> repeat with thissite in siteList
> try
> set WIP to item 1 of paragraphs of (do shell script "curl " &
> thissite & " | tr -cs '[0-9\\.]' '\\012' | awk -F'.' 'NF==4 && $1>0 &&
> $1<256 && $2<256 && $3<256 && $4<256 && !/\\.\\./'")
> if WIP is not missing value then exit repeat
> end try
> end repeat
> return WIP
> end WanIP
> So now I'm stuck, as the exact code I just posted (see above), doesn't
> work. The internet connection test code (when taken out) doesn't fix
> the issue, so my thinking is that there must be a newer way for the
> Wan IP address retrieval to occur in OS X 10.11, but I've not been
> able to figure it out as of yet.
> Any help is much appreciated.
> Thanks.
> _______________________________________________
> 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