class WinRM::WSMV::WriteStdin
WSMV
message to send stdin to a remote shell
Public Class Methods
new(session_opts, stdin_opts)
click to toggle source
# File lib/winrm/wsmv/write_stdin.rb, line 22 def initialize(session_opts, stdin_opts) validate_opts(session_opts, stdin_opts) init_ops(session_opts, stdin_opts) end
Protected Instance Methods
create_body(body)
click to toggle source
# File lib/winrm/wsmv/write_stdin.rb, line 33 def create_body(body) body << Gyoku.xml(stdin_body) end
create_header(header)
click to toggle source
# File lib/winrm/wsmv/write_stdin.rb, line 29 def create_header(header) header << Gyoku.xml(stdin_headers) end
Private Instance Methods
action_send()
click to toggle source
# File lib/winrm/wsmv/write_stdin.rb, line 61 def action_send { "#{NS_ADDRESSING}:Action" => 'http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Send', :attributes! => { "#{NS_ADDRESSING}:Action" => { 'mustUnderstand' => true } } } end
init_ops(session_opts, stdin_opts)
click to toggle source
# File lib/winrm/wsmv/write_stdin.rb, line 39 def init_ops(session_opts, stdin_opts) @session_opts = session_opts @shell_id = stdin_opts[:shell_id] @command_id = stdin_opts[:command_id] @stdin = stdin_opts[:stdin] @shell_uri = stdin_opts[:shell_uri] || RESOURCE_URI_CMD end
stdin_body()
click to toggle source
# File lib/winrm/wsmv/write_stdin.rb, line 73 def stdin_body { "#{NS_WIN_SHELL}:Send" => { "#{NS_WIN_SHELL}:Stream" => { '@Name' => 'stdin', '@CommandId' => @command_id, :content! => Base64.encode64(@stdin) } } } end
stdin_headers()
click to toggle source
# File lib/winrm/wsmv/write_stdin.rb, line 54 def stdin_headers merge_headers(shared_headers(@session_opts), resource_uri_shell(@shell_uri), action_send, selector_shell_id(@shell_id)) end
validate_opts(session_opts, stdin_opts)
click to toggle source
# File lib/winrm/wsmv/write_stdin.rb, line 47 def validate_opts(session_opts, stdin_opts) raise 'session_opts is required' unless session_opts raise 'stdin_opts[:shell_id] is required' unless stdin_opts[:shell_id] raise 'stdin_opts[:command_id] is required' unless stdin_opts[:command_id] raise 'stdin_opts[:stdin] is required' unless stdin_opts[:stdin] end