Skip to content

Commit

Permalink
#52 Add command and host name in the panic message
Browse files Browse the repository at this point in the history
  • Loading branch information
zshamrock committed Apr 27, 2018
1 parent 7f0245c commit e2513b7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions command/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ func SSH(sshConfig *ssh_config.Config, host, command string, ch chan ExecOutput)
}
client, err := ssh.Dial("tcp", fmt.Sprintf("%s:22", hostname), config)
if err != nil {
log.Panicln("Failed to dial:", err.Error())
log.Panicf("Failed to dial to the host %s: %v\n", host, err.Error())
}
session, err := client.NewSession()
if err != nil {
log.Panicln("Failed to create session:", err.Error())
log.Panicf("Failed to create session for the host %s: %v\n", host, err.Error())
}
defer session.Close()
var output strings.Builder
session.Stdout = &output
session.Stderr = os.Stderr
session.Stdin = os.Stdin
if err := session.Run(command); err != nil {
log.Panicln("Failed to run:", err.Error())
log.Panicf("Failed to run command \"%s\" on the host %s: %v\n", command, host, err.Error())
}
fmt.Fprintf(&output, "Command completed on the host %s\n", host)
ch <- ExecOutput{
Expand Down

0 comments on commit e2513b7

Please sign in to comment.