Sha256: 3ca872ad450e26650e1a62f6ecef7acb2d794c7863e374e965772c6a18e6260a

Contents?: true

Size: 1.45 KB

Versions: 15

Compression:

Stored size: 1.45 KB

Contents

# -*- coding: binary -*-
module Rex
module Script
class Base

  class OutputSink
    def print(msg); end
    def print_line(msg); end
    def print_status(msg); end
    def print_good(msg); end
    def print_error(msg); end
    def print_warning(msg); end
  end

  attr_accessor :client, :framework, :path, :error, :args
  attr_accessor :session, :sink, :workspace

  def initialize(client, path)
    self.client    = client
    self.framework = client.framework
    self.path      = path
    self.sink      = OutputSink.new

    if(client.framework.db and client.framework.db.active)
      self.workspace = client.framework.db.find_workspace( client.workspace.to_s ) || client.framework.db.workspace
    end

    # Convenience aliases
    self.session   = self.client
  end

  def output
    client.user_output || self.sink
  end

  def completed
    raise Rex::Script::Completed
  end

  def run(args=[])
    self.args = args = args.flatten
    begin
      eval(::File.read(self.path, ::File.size(self.path)), binding )
    rescue ::Interrupt
    rescue ::Rex::Script::Completed
    rescue ::Exception => e
      self.error = e
      raise e
    end
  end

  def print(*args);         output.print(*args);          end
  def print_status(*args);  output.print_status(*args);   end
  def print_error(*args);   output.print_error(*args);    end
  def print_good(*args);    output.print_good(*args);     end
  def print_line(*args);    output.print_line(*args);     end

end
end
end

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
rex-2.0.13 lib/rex/script/base.rb
rex-2.0.12 lib/rex/script/base.rb
rex-2.0.11 lib/rex/script/base.rb
rex-2.0.10 lib/rex/script/base.rb
rex-2.0.9 lib/rex/script/base.rb
rex-2.0.8 lib/rex/script/base.rb
rex-2.0.7 lib/rex/script/base.rb
rex-2.0.5 lib/rex/script/base.rb
rex-2.0.4 lib/rex/script/base.rb
dstruct-0.0.1 lib/rex/script/base.rb
rex-2.0.3 lib/rex/script/base.rb
librex-0.0.999 lib/rex/script/base.rb
rex-2.0.2 lib/rex/script/base.rb
librex-0.0.71 lib/rex/script/base.rb
librex-0.0.70 lib/rex/script/base.rb