Module: Multissh

Defined in:
lib/multissh.rb,
lib/multissh/version.rb

Constant Summary collapse

VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.run!Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/multissh.rb', line 8

def self.run!
  
  command = ARGV.join(' ')
  
  servers = []
  begin
   servers = STDIN.read_nonblock(4096).split(/[\s,]+/).map {|s| s.strip }
  rescue IO::EAGAINWaitReadable => e
    
  end

  unless(servers.size > 0)
    puts "Provide at least one hostname on stdin"
  end

  unless(command.strip.size > 0)
    puts "Provide a command to run as argument"
  end

  SSHKit.config.output_verbosity = Logger::DEBUG
  SSHKit.config.use_format :prettyhost

  on servers do |host|
    execute(command)
  end
end