Module: Ronin::Controls::Helpers::CommandExec
- Defined in:
- lib/ronin/controls/helpers/command_exec.rb
Instance Method Summary collapse
-
#cd(path) ⇒ String
Changes the current working directory of the shell.
-
#env ⇒ Hash
The environment variables to use in the shell.
-
#exec(command, *arguments) ⇒ Object
Execute a given command with optional arguments.
-
#ls(*arguments) ⇒ Array
Lists the contents of a given directory or the current working directory.
-
#pwd ⇒ String
The current working directory of the shell.
-
#sh(command, *args) ⇒ nil
Executes the specified command with the given arguments, and prints the output of the command.
-
#shell ⇒ Object
Starts an interactive shell for running commands.
Instance Method Details
#cd(path) ⇒ String
Changes the current working directory of the shell.
84 85 86 87 |
# File 'lib/ronin/controls/helpers/command_exec.rb', line 84 def cd(path) exec('cd',path) return path end |
#env ⇒ Hash
Returns The environment variables to use in the shell.
36 37 38 |
# File 'lib/ronin/controls/helpers/command_exec.rb', line 36 def env @env ||= {} end |
#exec(command, *arguments) ⇒ Object
Execute a given command with optional arguments.
51 52 53 |
# File 'lib/ronin/controls/helpers/command_exec.rb', line 51 def exec(command,*arguments) raise(NotImplemented,"the exec method has not been implemented",caller) end |
#ls(*arguments) ⇒ Array
Lists the contents of a given directory or the current working directory.
111 112 113 |
# File 'lib/ronin/controls/helpers/command_exec.rb', line 111 def ls(*arguments) exec('dir',*arguments).split(/\n\r?/) end |
#pwd ⇒ String
Returns The current working directory of the shell.
95 96 97 |
# File 'lib/ronin/controls/helpers/command_exec.rb', line 95 def pwd exec('pwd').chomp end |
#sh(command, *args) ⇒ nil
Executes the specified command with the given arguments, and prints the output of the command.
69 70 71 |
# File 'lib/ronin/controls/helpers/command_exec.rb', line 69 def sh(command,*args) puts exec(command,*args) end |
#shell ⇒ Object
Starts an interactive shell for running commands.
118 119 120 121 122 |
# File 'lib/ronin/controls/helpers/command_exec.rb', line 118 def shell UI::Shell.start(:prompt => '$') do |shell,line| sh(line) end end |