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


Click here to return to the 'An AppleScript to ssh to multiple hosts in iTerm' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
An AppleScript to ssh to multiple hosts in iTerm
Authored by: ElvisThePelvis on Jul 12, '07 09:24:46AM

Hmmm, this didn't seem to work with iTerm Build 0.9.5.0611. I didn't investigate further as to why, but perhaps someone else can easily point out why.



[ Reply to This | # ]
An AppleScript to ssh to multiple hosts in iTerm
Authored by: nvrmore100 on Jul 12, '07 12:28:10PM

Hmm will have to try the new version I guess. I am running Build 0.9.5.0517, works fine on there.



[ Reply to This | # ]
An AppleScript to ssh to multiple hosts in iTerm
Authored by: garyaj on Jul 12, '07 09:39:48PM

I had some problems with the script as posted. Here's my version using examples from the iTerm Help page:

-- Launch iTerm and log into multiple servers using SSH
tell application "iTerm"
	activate
	-- Read serverlist from file path below
	set Servers to paragraphs of (do shell script "/bin/cat $HOME/serverlist")
	repeat with nextLine in Servers
		-- If line in file is not empty (blank line) do the rest
		if length of nextLine is greater than 0 then
			set server to "nextLine"
			set term to (current terminal)
			-- Open a new tab
			tell term
				launch session "Default Session"
				tell the last session
					write text "ssh " & nextLine
					-- sleep to prevent errors if we spawn too fast
					do shell script "/bin/sleep 0.01"
				end tell
			end tell
		end if
	end repeat
	-- Close the first tab since we do not need it
	terminate the first session of the current terminal
end tell

The only difference is the use of 'launch session' instead of 'make new session at the end of sessions' and 'write text' instead of 'exec command'. Works a treat on iTerm 0.9.5.0611



[ Reply to This | # ]