本文整理汇总了Golang中github.com/masterzen/winrm/winrm.Shell.Close方法的典型用法代码示例。如果您正苦于以下问题:Golang Shell.Close方法的具体用法?Golang Shell.Close怎么用?Golang Shell.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/masterzen/winrm/winrm.Shell
的用法示例。
在下文中一共展示了Shell.Close方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: runCommand
func runCommand(shell *winrm.Shell, cmd *winrm.Command, rc *packer.RemoteCmd) {
defer shell.Close()
var wg sync.WaitGroup
copyFunc := func(w io.Writer, r io.Reader) {
defer wg.Done()
io.Copy(w, r)
}
if rc.Stdout != nil && cmd.Stdout != nil {
wg.Add(1)
go copyFunc(rc.Stdout, cmd.Stdout)
} else {
log.Printf("[WARN] Failed to read stdout for command '%s'", rc.Command)
}
if rc.Stderr != nil && cmd.Stderr != nil {
wg.Add(1)
go copyFunc(rc.Stderr, cmd.Stderr)
} else {
log.Printf("[WARN] Failed to read stderr for command '%s'", rc.Command)
}
cmd.Wait()
wg.Wait()
code := cmd.ExitCode()
log.Printf("[INFO] command '%s' exited with code: %d", rc.Command, code)
rc.SetExited(code)
}
示例2: runCommand
func runCommand(shell *winrm.Shell, cmd *winrm.Command, rc *packer.RemoteCmd) {
defer shell.Close()
go io.Copy(rc.Stdout, cmd.Stdout)
go io.Copy(rc.Stderr, cmd.Stderr)
cmd.Wait()
rc.SetExited(cmd.ExitCode())
}
示例3: runCommand
func runCommand(shell *winrm.Shell, cmd *winrm.Command, rc *packer.RemoteCmd) {
defer shell.Close()
go io.Copy(rc.Stdout, cmd.Stdout)
go io.Copy(rc.Stderr, cmd.Stderr)
cmd.Wait()
code := cmd.ExitCode()
log.Printf("[INFO] command '%s' exited with code: %d", rc.Command, code)
rc.SetExited(code)
}
示例4: runCommand
func runCommand(shell *winrm.Shell, cmd *winrm.Command, rc *remote.Cmd) {
defer shell.Close()
var wg sync.WaitGroup
go func() {
wg.Add(1)
io.Copy(rc.Stdout, cmd.Stdout)
wg.Done()
}()
go func() {
wg.Add(1)
io.Copy(rc.Stderr, cmd.Stderr)
wg.Done()
}()
cmd.Wait()
wg.Wait()
rc.SetExited(cmd.ExitCode())
}
示例5: runCommand
func runCommand(shell *winrm.Shell, cmd *winrm.Command, rc *packer.RemoteCmd) {
defer shell.Close()
if rc.Stdout != nil && cmd.Stdout != nil {
go io.Copy(rc.Stdout, cmd.Stdout)
} else {
log.Printf("[WARN] Failed to read stdout for command '%s'", rc.Command)
}
if rc.Stderr != nil && cmd.Stderr != nil {
go io.Copy(rc.Stderr, cmd.Stderr)
} else {
log.Printf("[WARN] Failed to read stderr for command '%s'", rc.Command)
}
cmd.Wait()
code := cmd.ExitCode()
log.Printf("[INFO] command '%s' exited with code: %d", rc.Command, code)
rc.SetExited(code)
}