Created
March 10, 2011 22:59
-
-
Save Burgestrand/865129 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
superman 127.0.0.1 Kim whoami | |
database 127.0.0.1 Kim sleep 1 && echo "Database says Hello!" | |
localhost 127.0.0.1 Kim date |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[superman] | |
Kim | |
[database] | |
Database says Hello! | |
[localhost] | |
Thu Mar 10 23:56:15 CET 2011 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/ssh' | |
ips = $stdin.readlines.map do |line| | |
label, host, user, command = line.split(' ', 4) | |
[label, Thread.new do | |
output = nil | |
Net::SSH.start(host, user) { |ssh| output = ssh.exec!(command) } | |
output.to_s | |
end, line] | |
end | |
ips.each do |(label, thread, _)| | |
puts "[#{label}]" | |
thread.value.each_line.map do |line| | |
puts " " + line | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment