Rickard von Essen 51a9a51699 Update winrm and winrmcp dependencies
Updated winrm and winrmcp dependencies. Relevant unit and acceptance tests passed successfully.

shell.Execute didn't return a Command object.

See f1bcf36a69/winrmcp/cp.go (L167) and 54ea5d0147/winrm/shell.go (L10-L22) respectively.

Closes #3763

Original patch by: Philipp Kosel <philipp.kosel@gmail.com>
2016-10-03 13:48:29 -07:00

37 lines
943 B
Go

package winrm
// Shell is the local view of a WinRM Shell of a given Client
type Shell struct {
client *Client
id string
}
// Execute command on the given Shell, returning either an error or a Command
func (s *Shell) Execute(command string, arguments ...string) (*Command, error) {
request := NewExecuteCommandRequest(s.client.url, s.id, command, arguments, &s.client.Parameters)
defer request.Free()
response, err := s.client.sendRequest(request)
if err != nil {
return nil, err
}
commandID, err := ParseExecuteCommandResponse(response)
if err != nil {
return nil, err
}
cmd := newCommand(s, commandID)
return cmd, nil
}
// Close will terminate this shell. No commands can be issued once the shell is closed.
func (shell *Shell) Close() error {
request := NewDeleteShellRequest(shell.client.url, shell.id, &shell.client.Parameters)
defer request.Free()
_, err := shell.client.sendRequest(request)
return err
}