File: shell.go

package info (click to toggle)
golang-github-masterzen-winrm 0.0~git20160323.0752679-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 256 kB
  • ctags: 180
  • sloc: makefile: 34; sh: 14
file content (31 lines) | stat: -rw-r--r-- 965 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package winrm

// Shell is the local view of a WinRM Shell of a given Client
type Shell struct {
	client  *Client
	ShellId string
}

// Execute command on the given Shell, returning either an error or a Command
func (shell *Shell) Execute(command string, arguments ...string) (cmd *Command, err error) {
	request := NewExecuteCommandRequest(shell.client.url, shell.ShellId, command, arguments, &shell.client.Parameters)
	defer request.Free()

	response, err := shell.client.sendRequest(request)
	if err == nil {
		var commandId string
		if commandId, err = ParseExecuteCommandResponse(response); err == nil {
			cmd = newCommand(shell, commandId)
		}
	}
	return
}

// Close will terminate this shell. No commands can be issued once the shell is closed.
func (shell *Shell) Close() (err error) {
	request := NewDeleteShellRequest(shell.client.url, shell.ShellId, &shell.client.Parameters)
	defer request.Free()

	_, err = shell.client.sendRequest(request)
	return
}