module Rem_Com

Public Class Methods

execute(user, pass, hostfile, commands) click to toggle source
# File lib/rem_com.rb, line 7
def self.execute(user, pass, hostfile, commands)
  begin
    File.open(hostfile).each {
        |i|
      Net::SSH.start( i.chomp, user, :password => pass ) do|ssh|
        result = ssh.exec!(commands)
        puts result
      end
    }
  rescue
    puts("Please verify that the your username, password and hostfile have been defined")
    puts "Hostfile is present" if File.exists?(hostfile)
    puts defined?(user) ? "User is defined as user #{user}" : 'User variable is not set...'
    puts defined?(pass) ? "Password has been set" : 'Password has not been set'
    puts defined?(commands) ? "Have been issued and ready for execution" : 'Commands have not been given'
  end

end
status(user, pass, hostfile) click to toggle source
# File lib/rem_com.rb, line 26
def self.status(user, pass, hostfile)
  begin
    File.open(hostfile).each {
        |i|
      Net::SSH.start( i.chomp, user, :password => pass ) do|ssh|
        result = ssh.exec!('hostname')
        puts result
      end
    }
  rescue
    puts "Hostfile is present" if File.exists?(hostfile)
    puts defined?(user) ? "User is defined as user #{user}" : 'User variable is not set...'
    puts defined?(pass) ? "Password has been set" : 'Password has not been set'
    puts defined?(commands) ? "Have been issued and ready for execution" : 'Commands have not been given'
  end

end