Module: IcingaCertService::Executor
- Included in:
- Client
- Defined in:
- lib/cert-service/executor.rb
Overview
SubModule to execute some commands
Instance Method Summary collapse
-
#exec_command(params) ⇒ Hash, #read
execute system commands with a Open3.popen2() call.
Instance Method Details
#exec_command(params) ⇒ Hash, #read
execute system commands with a Open3.popen2() call
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/cert-service/executor.rb', line 18 def exec_command( params ) cmd = params.dig(:cmd) return { code: 1, message: 'no command found' } if( cmd.nil? ) result = {} Open3.popen2( cmd ) do |_stdin, stdout_err, wait_thr| return_value = wait_thr.value result = { code: return_value.success?, message: stdout_err.gets } end result end |