(sshCommand string, isEncryptedOutput bool)
| 784 | } |
| 785 | |
| 786 | func (instance *SSHRemote) exeSSHCommandConsole(sshCommand string, isEncryptedOutput bool) (outContent string, err error) { |
| 787 | if len(sshCommand) <= 0 { |
| 788 | return "", nil |
| 789 | } |
| 790 | |
| 791 | session, err := instance.Connection.NewSession() |
| 792 | CheckError(err) |
| 793 | |
| 794 | // 在ssh主机上执行命令 |
| 795 | SmartIDELog.Debug(fmt.Sprintf("SSH Console %v:%v -> %v ......", instance.SSHHost, instance.SSHPort, sshCommand)) |
| 796 | out, err := session.CombinedOutput(sshCommand) |
| 797 | outContent = string(out) |
| 798 | defer session.Close() |
| 799 | |
| 800 | // 空错误判断 |
| 801 | if err != nil { |
| 802 | if outContent == "" && err.Error() == "Process exited with status 1" { |
| 803 | SmartIDELog.Debug(i18n.GetInstance().Common.Debug_empty_error) |
| 804 | } |
| 805 | } |
| 806 | |
| 807 | // 记录日志,有些情况下不想输出信息,比如cat id_rsa时 |
| 808 | outContent = strings.Trim(outContent, "\n") |
| 809 | if isEncryptedOutput { |
| 810 | SmartIDELog.AddEntryptionKeyWithReservePart(outContent) |
| 811 | } |
| 812 | SmartIDELog.Debug(fmt.Sprintf("SSH Console %v:%v -> %v >> `%v`", |
| 813 | instance.SSHHost, instance.SSHPort, sshCommand, outContent)) |
| 814 | |
| 815 | return outContent, err |
| 816 | } |
| 817 | |
| 818 | // 实时执行 |
| 819 | func (instance *SSHRemote) ExecSSHCommandRealTime(sshCommand string) (err error) { |
no test coverage detected