Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/lib/rex/script/base.rb
Views: 11779
# -*- coding: binary -*-1module Rex2module Script3class Base45class OutputSink6def print(msg); end7def print_line(msg); end8def print_status(msg); end9def print_good(msg); end10def print_error(msg); end11alias_method :print_bad, :print_error12def print_warning(msg); end13end1415attr_accessor :client, :framework, :path, :error, :args16attr_accessor :session, :sink, :workspace1718def initialize(client, path)19self.client = client20self.framework = client.framework21self.path = path22self.sink = OutputSink.new2324if(client.framework.db and client.framework.db.active)25self.workspace = client.framework.db.find_workspace( client.workspace.to_s ) || client.framework.db.workspace26end2728# Convenience aliases29self.session = self.client30end3132def output33client.user_output || self.sink34end3536def completed37raise Rex::Script::Completed38end3940def run(args=[])41self.args = args = args.flatten42begin43eval(::File.read(self.path, ::File.size(self.path)), binding )44rescue ::Interrupt45rescue ::Rex::Script::Completed46rescue ::Exception => e47self.error = e48raise e49end50end5152def print(*args); output.print(*args); end53def print_status(*args); output.print_status(*args); end54def print_error(*args); output.print_error(*args); end55def print_good(*args); output.print_good(*args); end56def print_line(*args); output.print_line(*args); end5758end59end60end61626364