class CommandLine_Exe
Attributes
exe_path[RW]
Public Class Methods
new(exe_name,*params)
click to toggle source
# File lib/exe_command.rb, line 9 def initialize(exe_name,*params) @exe_name = exe_name @exe_path = if params.empty? || params.first.nil? executable_path exe_name else params.first end end
Public Instance Methods
executable_path(exe_name)
click to toggle source
# File lib/exe_command.rb, line 22 def executable_path(exe_name) Utilities.which(exe_name) end
Private Instance Methods
run(cmd)
click to toggle source
# File lib/exe_command.rb, line 28 def run(cmd) retSuccess = false exec_time_sec = 0 stdout = nil run_details = Hash.new if @exe_path.nil? || !(File.exists? @exe_path) $log_detercomp.warn "unable to find #{@exe_name}" unless $log_detercomp.nil? else start_time = Time.now stdout, stderr, status = Open3.capture3(cmd) stop_time = Time.now exec_time_sec = (stop_time - start_time) if status.success? $log_detercomp.info "#{cmd} - success" unless $log_detercomp.nil? else err_msg = "#{cmd} - #{stdout}" $log_detercomp.error err_msg unless $log_detercomp.nil? end run_details[:cmd] = cmd run_details[:stdout] = stdout run_details[:exec_time_sec] = exec_time_sec retSuccess = status.success? ? true : false end return retSuccess,run_details end