Skip to content

Instantly share code, notes, and snippets.

@rickhull
Forked from Toggie/runcmd.rb
Last active August 29, 2015 14:23
Show Gist options
  • Save rickhull/7feaf1fb643f37169f28 to your computer and use it in GitHub Desktop.
Save rickhull/7feaf1fb643f37169f28 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'net/ssh'
filename = ARGV.shift || raise("no filename provided")
user = ARGV.shift || raise("no host provided")
pass = ARGV.shift || raise("no user provided")
File.open(filename).each do |i|
host = i.chomp
print "#{host}: "
Net::SSH.start(host, user, :password => pass ) do|ssh|
result = ssh.exec!('uptime')
puts result
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment