Here’s what I pieced together. Error when subs are called more than once…
set answer to "Refresh"
set secsbetween to 5 -- seconds
repeat while answer is "Refresh"
display dialog "IP Address @ " & GetCity() & ", " & GetCountry() & ".
Press OK to start monitoring for IP changes." default answer getExternalIP() with icon caution buttons {"Refresh", "Cancel", "OK"} default button 3
set answer to text returned of result
end repeat
set InitialIP to answer
tell application "System Events"
repeat while exists application process "Transmission"
if getExternalIP() is not equal to InitialIP then
activate application "Transmission"
tell process "Transmission"
click menu item "Pause All" of menu 1 of menu bar item "Transfers" of menu bar 1
end tell
exit repeat
end if
delay secsbetween
end repeat
end tell
(*===================== SUBROUTINES =======================*)
on GetCity()
try
set webResults to do shell script "curl [url=http://www.ipligence.com/geolocation]http://www.ipligence.com/geolocation"[/url]
set text item delimiters to "City: "
set a to item 2 of (text items of webResults)
set text item delimiters to "<"
set GetCity to item 1 of (text items of a)
set text item delimiters to ""
on error errText number errNum
log {errText, errNum}
--Capture the error
display dialog errText
set GetCity to "unknown"
end try
return GetCity
end GetCity
on GetCountry()
try
set webResults to do shell script "curl [url=http://www.ipligence.com/geolocation]http://www.ipligence.com/geolocation"[/url]
set text item delimiters to "Country: "
set a to item 2 of (text items of webResults)
set text item delimiters to "<"
set getCounty to item 1 of (text items of a)
set text item delimiters to ""
on error errText number errNum
log {errText, errNum}
--Capture the error
display dialog errText
set getCounty to "unknown"
end try
return getCounty
end GetCountry
on getExternalIP()
try
set webResults to do shell script "curl [url=http://checkip.dyndns.org/]http://checkip.dyndns.org/"[/url]
set text item delimiters to "Current IP Address: "
set a to item 2 of (text items of webResults)
set text item delimiters to "<"
set externalIP to item 1 of (text items of a)
set text item delimiters to ""
on error errText number errNum
log {errText, errNum}
--Capture the error
display dialog errText
set externalIP to "unknown"
end try
return externalIP
end getExternalIP