class RemoteExec::Local

Class to run local commands and transfer files localy.

Attributes

shell[R]

name of the shell to run

Public Class Methods

new(shell = "sh") click to toggle source

Constructs a new Local object.

@param shell [String] name of the shell to run @yield [self] if a block is given then the constructed

object yields itself and calls `#shutdown`
at the end, closing the remote connection
Calls superclass method RemoteExec::Base::new
# File lib/remote-exec/local.rb, line 22
def initialize(shell = "sh")
  @shell = shell
  super()
end

Public Instance Methods

execute(command) { |out, err| ... } click to toggle source

Execute command locally

@param command [String] command string to execute @return [Integer] exit status of the command

# File lib/remote-exec/local.rb, line 33
def execute(command)
  before_execute.changed_and_notify(self, command)
  shell_session.execute(command) do |out,err|
    on_execute_data.changed_and_notify(self, out, err)
    yield(out, err) if block_given?
  end
  last_status = shell_session.status
  after_execute.changed_and_notify(self, command, last_status)
  last_status
end

Private Instance Methods

shell_session() click to toggle source
# File lib/remote-exec/local.rb, line 46
def shell_session
  @shell_session ||= Session::Sh.new(:prog => shell).tap do |shell|
    after_connect.changed_and_notify(self)
  end
end