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: platon on Nov 30, '04 12:12:21PM
I just wrote another AppleScript before reading this hint, and added an entry ip to my tcsh's aliases. Whenever I have to ssh to my computer I call my daughter or wife at home to type ip and hit return in Terminal (I run Terminal instead of Finder, so after reboot it's always frontmost). Here's my script:

	set check_ip to do shell script "curl" as string
	set head_position to offset of "Current IP Address: " in check_ip
	set body_end_position to offset of "</body></html>" in check_ip
	set text_ip to characters head_position thru (body_end_position - 1) in check_ip as string
	set my_ip to characters (head_position + 20) thru (body_end_position - 1) in check_ip as string
	set display_ip to display dialog "  " & return & "       " & text_ip & return & "   " buttons ["Copy to Clipboard", "OK"] default button "OK" giving up after "150"
	if button returned of display_ip is "Copy to Clipboard" then
		set the clipboard to my_ip
	end if
on error the error_message number the error_number
	display dialog "Error: " & the error_number & return & the error_message buttons {"OK"} default button "OK" giving up after "30"
end try
Three fingertips away. Very handy.

[ Reply to This | # ]