« Religion makes the stupid, part #32498 | Main | Oh lord, here we go again »

Today on Stupid AppleScript Tricks

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:
, , ,


Categories:     Applescript, Mac OS X Scripts, Network Notes
Posted by John C. Welch at 09:11 | Permalink



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 characters 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.
digital.forest Where Internet solutions grow

There, a PayPal Button.

Bing
About the Author
How I do stuff on this site
Family
The Artwork of Melissa Findley
Diane Francis @ the National Post Eric Francis @ the Calgary Sun

BUY MY BOOK! BUY MY BOOK!
Non-DRM eBook PDF:
Get it direct from Peachpit!

Kindle Version:


Dead Tree Version:


Apple Amazon Links
Mac OS X Server 10.6 Snow Leopard

Mac OS X 10.6 Snow Leopard

Mac OS X 10.6 Snow Leopard Family Pack (5-User)

Amazon Book Links
Legacy of Ashes: The History of the CIA

The Donnas: Bitchin'

Wizards at War (The Young Wizards, Book 8)

The Demon's Sermon on the Martial Arts

The Collected Stories of Arthur C. Clarke

JavaScript and Ajax for the Web, Sixth Edition

Awakening Warrior: Revolution in the Ethics of Warfare

FOB Links

Mac Web Writers

Techie Links

Review Victims