On Fri, Jul 10, 2009 at 9:13 AM, Bryan<bryanv...@gmail.com> wrote: > I am trying to automate rsync to backup server A from server B. I > have set up a private/public key between the two servers so I don't > have to enter a password when using rsync. Running rsync manually > with the following command works fine: > rsync -av --dry-run -e "/usr/bin/ssh -i /home/bry/keys/brybackup.key" > r...@10.0.45.67:/home/bry/jquery.lookup /home/bry/tmp > > But when I try to do it with python, the subprocess simply returns the > ssh -h output on stderr like I am passing some invalid syntax. What > is wrong in my translation of rsync's -e command from shell to > pythyon? > > #! /usr/bin/python > from subprocess import Popen, PIPE > rsyncExec = '/usr/bin/ssh' > source = 'r...@10.0.45.67:/home/bry/jquery.lookup' > dest = '/home/bry/tmp' > rshArg = '-e "/usr/bin/ssh -i /home/bry/keys/brybackup.key"' > args = [rsyncExec, '-a', '-v', '--dry-run', rshArg, source, dest]
Like many problems involving the subprocess module, I think you've tokenized the arguments incorrectly. Try: rshArg = '"/usr/bin/ssh -i /home/bry/keys/brybackup.key"' args = [rsyncExec, '-av', '--dry-run', '-e', rshArg, source, dest] Note that the -e switch and its operand are separate arguments for the purposes of POSIX shell tokenization. Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list