Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'An AppleScript to obtain the WAN IP address' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
An AppleScript to obtain the WAN IP address
Authored by: bostmass on Nov 14, '04 03:03:48AM
Thought this might be a nice one-line addition to copy the answer to the clipboard.

WanIP()

display dialog "Copy this IP to clipboard? " default answer WanIP()
set the clipboard to WanIP()

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


[ Reply to This | # ]