Class: Msf::Util::Helper
- Inherits:
-
Object
- Object
- Msf::Util::Helper
- Defined in:
- lib/msf/util/helper.rb
Class Method Summary collapse
-
.which(cmd) ⇒ Object
Cross-platform way of finding an executable in the $PATH.
Class Method Details
.which(cmd) ⇒ Object
Cross-platform way of finding an executable in the $PATH.
which('ruby') #=> /usr/bin/ruby
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/msf/util/helper.rb', line 9 def self.which(cmd) exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| exts.each { |ext| exe = File.join(path, "#{cmd}#{ext}") return exe if File.executable?(exe) && !File.directory?(exe) } end return nil end |