Last Updated: February 25, 2016
·
2.566K
· ranman

SSH to many hosts and broadcast input with iTerm

Want a way to broadcast output to a ton of hosts at once?

Want to do it in the worst possible way? Well here's your apple script.

set hostList to {"jsl1", "jsl2", "jsl3", "jsl4", "jsl5", "jsl6", "jsl7", "jsl8"} as list

tell application "iTerm"
    activate
    set myTerm to (make new terminal)
    tell myTerm
        repeat with hostItem in hostList
            set Lsession to (launch session "Default Session")
            tell Lsession
                write text "ssh " & hostItem
            end tell
        end repeat
    end tell
end tell

tell application "System Events"
    tell process "iTerm"
        keystroke "I" using {command down}
    end tell
end tell