I made few changes to what I posted and it seems to work.
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 set theWIP to WanIP() # EDITED display alert "Your IP Address is " & theWIP & " And has been copied to your clipboard." # EDITED set the clipboard to theWIP # EDITED else if the button_pressed is "PingIPOrDomainName" then set IP_address to "" set dialog_1 to display dialog "Enter IP Address:" default answer "" with title "Ping IP Address" 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 else display alert "Thank you for using this application. If you liked using this application, please consider donating by visiting the application website and clicking on donate. Any amount donated would be greatly appreciated. Would you like to file a bug report? Visit the main application website?Or quit?" buttons {"FileBugReport", "VisitApplicationWebSite", "Quit"} cancel button "Quit" set the button_pressed to the button returned of the result #Buttons if the button_pressed is "VisitApplicationWebSite" then open location VisitApplicationWebSite else if the button_pressed is "FileBugReport" then open location FileBugReport end if end if end if
on WanIP() set WIP to missing value 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
Yvan KOENIG (VALLAURIS, France) lundi 10 août 2015 19:44:54
|