command execution using open3, with a post execution block
def cmd_exe(cmd, &block)
output = nil
log_to_scribe("JR-ncpr-upload"," executing command #{cmd}")
Open3.popen3(cmd) do |stdin, stdout, stderr|
output = stdout.readlines
error = stderr.readlines
unless error.empty?
p "#{cmd} Failed "
log_to_scribe("JR-ncpr-upload","#{cmd} Failed, with error #{error.to_s}")
yield false if block_given?
raise JobRunnerErrors::JobFailed("#{cmd} Failed, with error #{error.to_s}")
end
end
yield true if block_given?
output
end