Class: Rex::Script::Base
- Inherits:
-
Object
- Object
- Rex::Script::Base
- Defined in:
- lib/rex/script/base.rb
Direct Known Subclasses
Defined Under Namespace
Classes: OutputSink
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
-
#client ⇒ Object
Returns the value of attribute client.
-
#error ⇒ Object
Returns the value of attribute error.
-
#framework ⇒ Object
Returns the value of attribute framework.
-
#path ⇒ Object
Returns the value of attribute path.
-
#session ⇒ Object
Returns the value of attribute session.
-
#sink ⇒ Object
Returns the value of attribute sink.
-
#workspace ⇒ Object
Returns the value of attribute workspace.
Instance Method Summary collapse
- #completed ⇒ Object
-
#initialize(client, path) ⇒ Base
constructor
A new instance of Base.
- #output ⇒ Object
- #print(*args) ⇒ Object
- #print_error(*args) ⇒ Object
- #print_good(*args) ⇒ Object
- #print_line(*args) ⇒ Object
- #print_status(*args) ⇒ Object
- #run(args = []) ⇒ Object
Constructor Details
#initialize(client, path) ⇒ Base
Returns a new instance of Base.
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rex/script/base.rb', line 18 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 |
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
15 16 17 |
# File 'lib/rex/script/base.rb', line 15 def args @args end |
#client ⇒ Object
Returns the value of attribute client.
15 16 17 |
# File 'lib/rex/script/base.rb', line 15 def client @client end |
#error ⇒ Object
Returns the value of attribute error.
15 16 17 |
# File 'lib/rex/script/base.rb', line 15 def error @error end |
#framework ⇒ Object
Returns the value of attribute framework.
15 16 17 |
# File 'lib/rex/script/base.rb', line 15 def framework @framework end |
#path ⇒ Object
Returns the value of attribute path.
15 16 17 |
# File 'lib/rex/script/base.rb', line 15 def path @path end |
#session ⇒ Object
Returns the value of attribute session.
16 17 18 |
# File 'lib/rex/script/base.rb', line 16 def session @session end |
#sink ⇒ Object
Returns the value of attribute sink.
16 17 18 |
# File 'lib/rex/script/base.rb', line 16 def sink @sink end |
#workspace ⇒ Object
Returns the value of attribute workspace.
16 17 18 |
# File 'lib/rex/script/base.rb', line 16 def workspace @workspace end |
Instance Method Details
#completed ⇒ Object
36 37 38 |
# File 'lib/rex/script/base.rb', line 36 def completed raise Rex::Script::Completed end |
#output ⇒ Object
32 33 34 |
# File 'lib/rex/script/base.rb', line 32 def output client.user_output || self.sink end |
#print(*args) ⇒ Object
52 |
# File 'lib/rex/script/base.rb', line 52 def print(*args); output.print(*args); end |
#print_error(*args) ⇒ Object
54 |
# File 'lib/rex/script/base.rb', line 54 def print_error(*args); output.print_error(*args); end |
#print_good(*args) ⇒ Object
55 |
# File 'lib/rex/script/base.rb', line 55 def print_good(*args); output.print_good(*args); end |
#print_line(*args) ⇒ Object
56 |
# File 'lib/rex/script/base.rb', line 56 def print_line(*args); output.print_line(*args); end |
#print_status(*args) ⇒ Object
53 |
# File 'lib/rex/script/base.rb', line 53 def print_status(*args); output.print_status(*args); end |
#run(args = []) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/rex/script/base.rb', line 40 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 |