How to solve the error of the rsync error: error in IPC code (code 14) at pipe.c(85) [sender=3.1.2]
Asked Answered
H

1

0

I'm using a command of rsync for making a new directory to save the images the command is "rsync -ave --rsync-path='mkdir -p " + path + " && rsync' " + filePath + " ubuntu@" + LocalhostIp + ":" + path but while running my code this command will gives me the error the error is

Error:

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]

Edit

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
}

How can I solve this error?

Hymnology answered 19/11, 2018 at 5:53 Comment(4)
In ExecuteCommand func replace cmd := exec.Command("sh", "-c",command) with cm := []string{"-c"} cm = append(cm, strings.Split(command, " ")...) cmd := exec.Command("sh", cm...)Gerda
@Gerda the solution you tell I applied it into my code and run but It gives me error of exit status 1: rsync version 3.1.2 protocol version 31 Copyright (C) 1996-2015 by Andrew Tridgell, Wayne Davison, and others. Web site: http://rsync.samba.org/Hymnology
Can you ensure your rsync -ave --rsync-path='mkdir -p " + path + " && rsync' " + filePath + " ubuntu@" + LocalhostIp + ":" + path command work from your pc? And also it will be easy to me if you give the value of the variable, so that i can check.Gerda
@Gerda I run this rsync -ave --rsync-path="mkdir -p /var/www/html/uploads/ironnetwork/ && rsync" /var/www/html/uploads/ironnetwork/1542607804image. command directly in the terminal and it will give me the error sending incremental file list rsync: change_dir "/var/www/html/uploads/ironnetwork" failed: No such file or directory (2) Now Can you solve my problem?Hymnology
S
1

You need to remove the -e option, as this is taking the following work (--rsync-path=...) as the replacement for the ssh command. For example,

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

Just use -av.

Subatomic answered 19/11, 2018 at 8:14 Comment(10)
As you say @Subatomic I remove the flag -e and then I run the command then it will give me the error exit status 1: rsync version 3.1.2 protocol version 31 Copyright (C) 1996-2015 by Andrew Tridgell, Wayne Davison, and others.Hymnology
exit 1 is a syntax error in the arguments. Perhaps your path or filePath strings have characters that are being interpreted by the shell. Try adding -x in your ExecuteCommand, (cmd := exec.Command("sh", "-xc",command)) to see what is actually being passed to rsync.Subatomic
now it will print this exit status 1: + rsync rsync version 3.1.2 protocol version 31Hymnology
I don't know the go language, so I cannot help you with this. You are not getting the entire error message. Perhaps you introduced a typing error when you converted the -ave to -av.Subatomic
Can you tell me how I run this command successfully on ubuntu terminal? @SubatomicHymnology
I presume you should be typing a command like: rsync -av --rsync-path="mkdir -p /var/www/html/uploads/ironnetwork/ && rsync" /var/www/html/uploads/ironnetwork/1542607804image ubuntu@remotehost:/var/www/html/uploads/ironnetwork/Subatomic
it was asking for the password what should I write there?Hymnology
This has gone too far away from the original question. I suggest you look back at what you are trying to achieve, simplify it, and start a new question, referring back to this one if appropriate.Subatomic
actually I told you what I gona achieve is that I want to write an image from the live this image into my desktop using rsync command. Can you help me to do this?Hymnology
see this questionHymnology

© 2022 - 2024 — McMap. All rights reserved.