module Ohai::Util::FileHelper

Public Instance Methods

which(cmd) click to toggle source
# File lib/ohai/util/file_helper.rb, line 24
def which(cmd)
  paths = ENV["PATH"].split(File::PATH_SEPARATOR) + [ "/bin", "/usr/bin", "/sbin", "/usr/sbin" ]
  paths.each do |path|
    filename = File.join(path, cmd)
    if File.executable?(filename)
      logger.trace("Plugin #{name}: found #{cmd} at #{filename}")
      return filename
    end
  end
  logger.trace("Plugin #{name}: did not find #{cmd}")
  false
end