Use applscript to execute dig and launch remote desktop
I don't know applescript, but I need to automate the fo开发者_开发知识库llowing steps, and it seems that applsescript is the way to go.
1) run the terminal command "dig @123.4.5.678 computername.domain.net +short" 2) Capture the returned IP address 3) Launch Microsoft remote desktop passing in the captured IP address.
Is this possible? what commands do i use? Is there a good tutorial somewhere?
To run a shell script from Applescript you use the command
do shell script "mycommand"
where mycommand is the shell command you are executing.
Microsoft's Remote Desktop is probably not scriptable. (I don't use it and can't say) However you can use what is called GUI scripting to script other applications.
You could then have a script somewhat like this (note untested)
set a to do shell script "myscript"
tell application "Finder" to set the clipboard to a
tell application "Remote Desktop Connection" to activate
tell application "System Events"
tell process "Remote Desktop Connection" to keystroke "v" using command down
end tell
The GUI scripting basically tells RDC to paste the clipboard into the field for your IP.
The tutorial on GUI scripting can be found here:
http://www.macosxautomation.com/applescript/uiscripting/index.html
There are lots of general Applescript tutorials such as here:
http://homepage.mac.com/swain/Macinchem/Applescript/AppScript_tut/AppScrip_tut_1/appscript_tut_1.htm
精彩评论