diff --git a/src/framework/utils/ssh/sftp.go b/src/framework/utils/ssh/sftp.go index 2fd826fc..f5c103f7 100644 --- a/src/framework/utils/ssh/sftp.go +++ b/src/framework/utils/ssh/sftp.go @@ -80,7 +80,7 @@ func (s *SSHClientSFTP) CopyDirLocalToRemote(localDir, remoteDir string) error { } else { // 如果是文件,则复制文件内容 if err := s.CopyFileLocalToRemote(localPath, remotePath); err != nil { - logger.Errorf("CopyFileLocalToRemote failed to opening local file %s: => %s", localPath, err.Error()) + logger.Errorf("CopyDirLocalToRemote failed to copying remote file %s: => %s", localPath, err.Error()) return err } } @@ -88,7 +88,7 @@ func (s *SSHClientSFTP) CopyDirLocalToRemote(localDir, remoteDir string) error { return nil }) if err != nil { - logger.Errorf("CopyDirLocalToRemote failed to walking local directory: => %s", err.Error()) + logger.Errorf("CopyDirLocalToRemote failed to walking remote directory: => %s", err.Error()) return err } return nil @@ -134,6 +134,12 @@ func (s *SSHClientSFTP) CopyFileLocalToRemote(localPath, remotePath string) erro } defer localFile.Close() + // 创建远程目录 + // if err := s.Client.MkdirAll(filepath.Dir(remotePath)); err != nil { + // logger.Errorf("CopyFileLocalToRemote failed to creating remote directory %s: => %s", remotePath, err.Error()) + // return err + // } + // 创建远程文件 remoteFile, err := s.Client.Create(remotePath) if err != nil { diff --git a/src/framework/utils/ssh/ssh.go b/src/framework/utils/ssh/ssh.go index 29a5fb70..d70991e7 100644 --- a/src/framework/utils/ssh/ssh.go +++ b/src/framework/utils/ssh/ssh.go @@ -100,6 +100,7 @@ func (c *ConnSSH) RunCMD(cmd string) (string, error) { defer session.Close() buf, err := session.CombinedOutput(cmd) if err != nil { + logger.Infof("RunCMD failed run command: => %s", cmd) logger.Errorf("RunCMD failed run command: => %s", err.Error()) } c.LastResult = string(buf)