Python popen rsync with rsh parameter

I am trying to execute rsync command through a subprocess and popen. Everything is fine until I put the rsh subcommand, where everything goes wrong.

from subprocess import Popen
args = ['-avz', '--rsh="ssh -C -p 22 -i /home/bond/.ssh/test"', 'bond@localhost:/home/bond/Bureau', '/home/bond/data/user/bond/backups/']

p = Popen(['rsync'] + args, shell=False)
print p.wait()

#just printing generated command:
print ' '.join(['rsync']+args)

I tried to avoid "-rsh =" ssh -C -p 22 -i / home / bond / .ssh / test "in different ways, but it seems like this is not a problem.

I get an error rsync: Failed to execute exec ssh -C -p 22 -i / home / bond / .ssh / test: There is no such file or directory (2)

If I copy / paste the same arguments that I was outputting at that time, I get the correct execution of the command.

Thank.

+5
source share
2 answers

What happens if you use instead '--rsh=ssh -C -p 22 -i /home/bond/.ssh/test'(I removed the double quotes).

, . , / , , , , -C -p .. . subprocess.Popen , , , .

+5

, . , ssh . , script rsync, subprocess.call(['rsyncscript', src, dest, sshkey]). script :/usr/bin/rsync -az -e "ssh -i $3" ​​$ 1 $2

.

0

All Articles