module KnifeCssh

Constants

VERSION

Public Class Methods

find_command(*cmds) click to toggle source
# File lib/chef/knife/cssh-summon.rb, line 20
def self.find_command(*cmds)
  cmd = self.which *cmds
  return cmd if not cmd.nil?

  nil
end
which(*cmds) click to toggle source
# File lib/chef/knife/cssh-summon.rb, line 5
def self.which(*cmds)
  exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']

  cmds.each do |cmd|
    ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
      exts.each do |ext|
        exe = File.join(path, "#{cmd}#{ext}")
        return exe if File.executable?(exe) && !File.directory?(exe)
      end
    end
  end

  return nil
end