class Rex::Script::Base

Attributes

args[RW]
client[RW]
error[RW]
framework[RW]
path[RW]
session[RW]
sink[RW]
workspace[RW]

Public Class Methods

new(client, path) click to toggle source
# File lib/rex/script/base.rb, line 17
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

Public Instance Methods

completed() click to toggle source
# File lib/rex/script/base.rb, line 35
def completed
  raise Rex::Script::Completed
end
output() click to toggle source
# File lib/rex/script/base.rb, line 31
def output
  client.user_output || self.sink
end
print(*args) click to toggle source
print_error(*args) click to toggle source
print_good(*args) click to toggle source
print_line(*args) click to toggle source
print_status(*args) click to toggle source
run(args=[]) click to toggle source
# File lib/rex/script/base.rb, line 39
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