Sha256: a049e8994720b144a302c1728140f9bff2852586dcd5ac50c1bfbe83da1066d2

Contents?: true

Size: 1.31 KB

Versions: 5

Compression:

Stored size: 1.31 KB

Contents

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
	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
		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

5 entries across 5 versions & 1 rubygems

Version Path
librex-0.0.6 lib/rex/script/base.rb
librex-0.0.5 lib/rex/script/base.rb
librex-0.0.4 lib/rex/script/base.rb
librex-0.0.3 lib/rex/script/base.rb
librex-0.0.1 lib/rex/script/base.rb