Class: WinRM::FS::Core::CommandExecutor
- Inherits:
-
Object
- Object
- WinRM::FS::Core::CommandExecutor
- Defined in:
- lib/winrm-fs/core/command_executor.rb
Overview
Executes commands used by the WinRM file management module
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(service) ⇒ CommandExecutor
constructor
A new instance of CommandExecutor.
- #open ⇒ Object
- #run_cmd(command, arguments = []) ⇒ Object
- #run_powershell(script) ⇒ Object
Constructor Details
#initialize(service) ⇒ CommandExecutor
Returns a new instance of CommandExecutor.
22 23 24 |
# File 'lib/winrm-fs/core/command_executor.rb', line 22 def initialize(service) @service = service end |
Instance Method Details
#close ⇒ Object
31 32 33 34 |
# File 'lib/winrm-fs/core/command_executor.rb', line 31 def close @service.close_shell(@shell) if @shell @shell_open = false end |
#open ⇒ Object
26 27 28 29 |
# File 'lib/winrm-fs/core/command_executor.rb', line 26 def open @shell = @service.open_shell @shell_open = true end |
#run_cmd(command, arguments = []) ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/winrm-fs/core/command_executor.rb', line 41 def run_cmd(command, arguments = []) assert_shell_is_open result = nil @service.run_command(@shell, command, arguments) do |command_id| result = @service.get_command_output(@shell, command_id) end assert_command_success(command, result) result.stdout end |
#run_powershell(script) ⇒ Object
36 37 38 39 |
# File 'lib/winrm-fs/core/command_executor.rb', line 36 def run_powershell(script) assert_shell_is_open run_cmd('powershell', ['-encodedCommand', encode_script(safe_script(script))]) end |