« Religion makes the stupid, part #32498 | Main | Oh lord, here we go again »
I know I'm reinventing a wheel here, but it took like five minutes, so who cares. Anyway, one thing that makes me bonkers about Apple Remote Desktop is that while I can run Unix commands on a remote machine with it, what I can't do is easily select a machine and just open an SSH session to it.
Well, now I can. Here's the script:
set theSSHList to {}
tell application "Remote Desktop"
set theComputers to the selection
repeat with x in theComputers
set the end of theSSHList to Internet address of x
end repeat
end tell
tell application "Terminal"
repeat with x in theSSHList
do script "ssh username@" & (contents of x)
end repeat
end tell
It's pretty simple. We initialize theSSHList, then grab all the selected computers in Remote Desktop. (Note...if you have Apple Remote Desktop open, there is always a selected computer as long as there's a computer in the window to select, so this will tend not to fail unless you're pointing at an empty computer. For obvious reasons, it won't work on a computer you haven't added to Apple Remote Desktop yet.)
We process the list of computers, and dump their IP addresses into theSSHList.
Next is to interate through theSSHList, and open a new ssh session for each item in theSSHList.
This won't bring Terminal to the front, by the way. I don't tend to like that, but if you do, then just add an "activate" command right after "tell application "Terminal"" and Terminal will merrily pop to the front.
Put that in your scripts menu and you can now easily pop ssh windows to Apple Remote Desktop computers when you need.
Technorati Tags:
AppleScript, Stupid AppleScript Tricks, Apple Remote Desktop, Apple Remote Desktop Scripting
Comments
Warning for Notes users: The commenting system uses HTML.I know this will be scary for some of you, especially Notes fans. However, open standards, rah-rah.
If you want to use less-than or greater-than signs, or other similar charachters that HTML reserves,
you'll simply have to learn to do it the HTML way. Luckily, HTML is kind of popular, no matter what
your re-educators have told you, and you can easily find help on the intertubes.

