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



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

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