Class: Pike::SSH::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/pike/ssh/runner.rb

Constant Summary collapse

SUDO_PATTERN =
/\[sudo\] password for .+:\s*$/

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection, cmd) ⇒ Runner

Constructor



13
14
15
16
17
18
# File 'lib/pike/ssh/runner.rb', line 13

def initialize(connection, cmd)
  @cmd = cmd
  @process = SSH::Process.new(@cmd)
  @connection = connection
  @state = :init
end

Class Method Details

.run(connection, cmd) ⇒ Object

Simple method to run commands on a connection



37
38
39
40
# File 'lib/pike/ssh/runner.rb', line 37

def self.run(connection, cmd)
  ins = self.new connection, cmd
  ins.run!
end

Instance Method Details

#run!Object

Executes the process of the current Runner instance



25
26
27
28
29
30
# File 'lib/pike/ssh/runner.rb', line 25

def run!
  @connection.open_channel &method(:run)
  @connection.wait!

  return @process
end