ubuntu - 如何解决rsync error : error in IPC code (code 14) at pipe. c(85) [sender=3.1.2]的报错

标签 ubuntu go rsync mkdir

我正在使用 rsync 命令创建一个新目录来保存图像命令是 "rsync -ave --rsync-path='mkdir -p "+ path + "&& rsync' "+ filePath + "ubuntu@"+ LocalhostIp + ":"+ path 但是在运行我的代码时这个命令会给我错误错误是

错误:

exit status 14: rsync: Failed to exec --rsync-path=mkdir: No such file or directory (2)

rsync error: error in IPC code (code 14) at pipe.c(85) [sender=3.1.2]

rsync: connection unexpectedly closed (0 bytes received so far) [sender]

rsync error: error in IPC code (code 14) at io.c(235) [sender=3.1.2]

编辑

func CopyUploadedFileToAppServers(filePath, path string) {
   ExecuteCommand("rsync -ave --rsync-path='mkdir -p " + path + " && rsync' " + filePath + " ubuntu@" + LocalhostIp + ":" + path)
}

func ExecuteCommand(command string) error{
 cmd := exec.Command("sh", "-c",command)
 var out bytes.Buffer
 var stderr bytes.Buffer
 cmd.Stdout = &out
 cmd.Stderr = &stderr

 err := cmd.Run()

 if err != nil {
    fmt.Println(fmt.Sprint(err) + ": " + stderr.String())
    return err
 }
 fmt.Println("Result: " + out.String())
 return nil
}

我该如何解决这个错误?

最佳答案

您需要删除 -e 选项,因为这是将以下工作 (--rsync-path=...) 替换为 ssh命令。例如,

$ rsync -ave --x_x  /tmp/a abc@localhost:/tmp/y
rsync: Failed to exec --x_x: No such file or directory (2)

只需使用-av

关于ubuntu - 如何解决rsync error : error in IPC code (code 14) at pipe. c(85) [sender=3.1.2]的报错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53369009/

相关文章:

node.js - 为 React Native 安装 Node.js

php - 对已连接设备的命令行输出进行排序

go - 用 n 个元素的数组初始化结构

linux - mac OS X 和 linux 之间的 rsync 所有权

concurrency - 通过同时运行多个实例来加速 rsync?

macos - rsync 在传输过程中突然无限期挂起

node.js - Node 请求实体太大 body-parser 限制设置

linux - Virtualbox - 更新后启动虚拟机失败

go - 具有对象映射的Avro模式?

go - 我想从 Goproxy 中删除我的私有(private)包