2013-02-22 77 views
0

我試圖得到這個工作運行rsync命令,但我不斷收到通過從cygwin的一個python腳本

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

-

bash: /usr/bin/rsync: cannot execute binary file 
126 
+0

做同樣的命令工作,如果你手工輸入在終端? – askewchan 2013-02-23 00:03:40

回答

1

你缺少了 '-c'(命令)選項打擊。你還應該提供rsync命令作爲一個字符串:

subprocess.call(['c:/cygwin/bin/bash.exe', '--login', '-i', '-c', 'rsync -zrgo --omit-dir-times --verbose --delete . [email protected]:/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> 
+0

令人驚歎!謝謝!如果我說,有一個小問題。它會嘗試使用當前的cygwin目錄,但這時如果我把完整路徑的目錄它告訴我,'源和目標不能同時remote.' – user391986 2013-02-23 00:12:56

+0

什麼是您使用的完整路徑?它有冒號(:)嗎? – isedev 2013-02-23 00:14:11

+0

的完整路徑是S:/ myproject的/根/所以我希望S:/ myproject的/根[email protected]:在/ var/WWW /項目/ – user391986 2013-02-23 00:15:43