user391986
user391986

Reputation: 30886

running rsync command through cygwin from a python script

I’m trying to get this working, but I keep getting

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

Upvotes: 0

Views: 976

Answers (1)

isedev
isedev

Reputation: 19601

You are missing the '-c' (command) option to bash. Also you should provide the rsync command as a single string:

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

From the man page:

-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.

For example:

# bash /bin/ls
/bin/ls: /bin/ls: cannot execute binary file
# bash -c "/bin/ls -l"
<ls output>

Upvotes: 1

Related Questions