>>>>> Chris Rebert <c...@rebertia.com> (CR) wrote: >CR> 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]
>CR> Like many problems involving the subprocess module, I think you've >CR> tokenized the arguments incorrectly. Try: >CR> rshArg = '"/usr/bin/ssh -i /home/bry/keys/brybackup.key"' >CR> args = [rsyncExec, '-av', '--dry-run', '-e', rshArg, source, dest] >CR> Note that the -e switch and its operand are separate arguments for the >CR> purposes of POSIX shell tokenization. I think you should have only one kind of quotes in rshArg: rshArg = "/usr/bin/ssh -i /home/bry/keys/brybackup.key" I haven't tried it, however, but this is just how Unix works. -- Piet van Oostrum <p...@cs.uu.nl> URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list