views:

134

answers:

2

Hi, with this command, I get only the file called OUTPUT (in reality I have many more --include flags) - so works as expected:

os.system("rsync --rsh=ssh -arvuP --include='OUTPUT' --exclude='*' user@host:there/ ./here")

In this case, the --include and --exclude flags are ignored:

subprocess.call("rsync --rsh=ssh -arvuP --include='OUTPUT' --exclude='*' user@host:there/ ./here".split())

I wonder what I am doing wrong? Thank you much!

Edit: Sorry, this is on OS X Leopard, and I get all the files...

+3  A: 

Try using subprocess.call with shell=True, it will simulate os.system more closely:

subprocess.call("...", shell=True)
orip
Thanks - but no luck. When I run with shell=True, it is as if I had typed rsync without any arguments...
Stephen
Did you remove the .split()?
orip
+1  A: 

Python does have an rsync module if I am not wrong, why not use that instead of a call. It will make your app more manageable.

whatnick
Ah, I did not know about that module - thanks for the tip. I'm curious as to the behavior of subprocess.call in this case though, as I feel I've followed the instructions and examples on how to use it closely - without success...
Stephen