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?
cmd := exec.Command("sh", "-c",command)
withcm := []string{"-c"} cm = append(cm, strings.Split(command, " ")...) cmd := exec.Command("sh", cm...)
– Gerdaexit 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/
– Hymnologyrsync -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. – Gerdarsync -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 errorsending 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