Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- !/usr/bin/env ruby
- require 'socket'
- require 'rubygems'
- require 'net/ssh'
- File.open(ARGV[0], "r") do |infile|
- while (line = infile.gets)
- host,username,password,command = line.chomp.split(',')
- Thread.new {
- if username == nil || password == nil then
- puts "#{host}: No username or password, skipping"
- Thread.exit
- end
- begin
- TCPSocket.new(host, 22)
- rescue
- puts "#{host}: Unknown host, skipping"
- Thread.exit
- end
- Net::SSH.start( host, username, :password => password) do |ssh|
- puts "#{host}: #{ssh.exec! command}"
- end
- }
- end
- while Thread.list.size > 1 do
- sleep 5
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement