Class: Moonshot::SSHForkExecutor

Inherits:
Object
  • Object
show all
Defined in:
lib/moonshot/ssh_fork_executor.rb

Overview

Run an SSH command via fork/exec.

Defined Under Namespace

Classes: Result

Instance Method Summary collapse

Instance Method Details

#run(cmd) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/moonshot/ssh_fork_executor.rb', line 10

def run(cmd)
  output = StringIO.new

  exit_status = nil
  Open3.popen3(cmd) do |_, stdout, _, wt|
    output << stdout.read until stdout.eof?
    exit_status = wt.value.exitstatus
  end

  Result.new(output.string.chomp, exit_status)
end