Skip to content

Instantly share code, notes, and snippets.

@t0d0r
Created September 12, 2017 09:04
Show Gist options
  • Save t0d0r/c805ed3ae87d13f145f01030175fd125 to your computer and use it in GitHub Desktop.
Save t0d0r/c805ed3ae87d13f145f01030175fd125 to your computer and use it in GitHub Desktop.

Revisions

  1. t0d0r created this gist Sep 12, 2017.
    23 changes: 23 additions & 0 deletions gista-file
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    data = <<__EOF__
    node-bg-os 127.0.0.1 127.0.0.1
    __EOF__

    require 'net/ssh'

    exit if ARGV[0].nil?

    count = 0
    data.split(/\n/).each do |line|
    name,ip1,ip = line.split(/\s+/)
    #puts "#{name}\n#{ip}\n#{ip}\n\n"
    print ">> #{name}: "
    Net::SSH.start(ip, 'user', :password => "PASSWORD") do |ssh|
    # capture all stderr and stdout output from a remote process
    output = ssh.exec!("#{ARGV[0]}")
    count += output.to_i
    puts output
    end
    # puts "speeping 60 sec"
    # sleep 60
    end
    puts "Total: #{count}"