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


Click here to return to the 'An AppleScript for the remote user' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
An AppleScript for the remote user
Authored by: waboom on Jul 12, '06 11:21:49PM
I do the same support for my family; to make it easier on them, I wrote this AppleScript for them to run. Since I may be traveling when they call for help, it prompts the user for an IP address or domain name to connect to before running the ssh command in terminal. It also does some quick sanity checking on the IP address to make sure it's a valid IPv4 address. Just change "ARDHero" at the top to your name, and "ARDHeroAccount" to whatever the account name is on your end that they should log into. Save as an application in Script Editor and you should be set.

set ARDHero to "Steve"
set ARDHeroAccount to "ard_acct"

set isValidIP to false
repeat while isValidIP is false
	set remoteIP to text returned of (display dialog "what is " & ARDHero & "'s IP address or Domain Name?" default answer "192.17.210.65")
	
	set savedTextItemDelimiters to AppleScript's text item delimiters
	try
		set isValidIP to true
		set AppleScript's text item delimiters to {"."}
		set IPList to every text item in remoteIP
		set countOfIP to count of IPList
		if countOfIP is not equal to 4 then set isValidIP to false
		repeat with index from 1 to countOfIP
			set currentValue to text item index of IPList as integer
			if currentValue > 255 then set isValidIP to false
		end repeat
		set AppleScript's text item delimiters to savedTextItemDelimiters
	on error -- In case something bogus happens, make sure the delimiter is set back
		set AppleScript's text item delimiters to savedTextItemDelimiters
		set isValidIP to false
	end try
	-- Check if they entered a domain name
	try
		last character of remoteIP as integer
	on error --if the last character isn't a number, it's a domain name
		set isValidIP to true
	end try
	if isValidIP is false then
		display dialog ("This is not a valid IP address:" & return & remoteIP) buttons "Try Again" default button "Try Again"
	else
		set x to button returned of (display dialog ("Is this the correct address?" & return & remoteIP) buttons {"No", "Yes"} default button "Yes")
		if x is "No" then set isValidIP to false
	end if
end repeat


tell application "Terminal"
	activate
	do script ("ssh " & ARDHeroAccount & "@" & remoteIP & " -R 5800:127.0.0.1:5900")
end tell


[ Reply to This | # ]