0

我试图让这个工作,但我一直在

subprocess.call(['c:/cygwin/bin/bash.exe', '--login', '-i', 'rsync', '-zrgo', '--omit-dir-times', '--verbose', '--delete', '.', 'usertwo@192.168.1.1:/var/www/project/'])

--

bash: /usr/bin/rsync: cannot execute binary file
126
4

1 回答 1

1

您缺少 bash 的“-c”(命令)选项。此外,您应该将 rsync 命令作为单个字符串提供:

subprocess.call(['c:/cygwin/bin/bash.exe', '--login', '-i', '-c', 'rsync -zrgo --omit-dir-times --verbose --delete . usertwo@192.168.1.1:/var/www/project/'])

从手册页:

-c string If the -c option is present,  then  commands  are  read  from
          string.   If  there  are arguments after the string, they are
          assigned to the positional parameters, starting with $0.

例如:

# bash /bin/ls
/bin/ls: /bin/ls: cannot execute binary file
# bash -c "/bin/ls -l"
<ls output>
于 2013-02-23T00:03:10.430 回答