I know this question has been asked few times already, just couldn't see what's wrong with my usage.
Usage#1
proc = subprocess.Popen(['/usr/bin/find', '/path/to/dir', '-type', 'f', '-name', '"*.gradle"', '-exec', 'grep', '"KEYWORD"', '{}', '/dev/null', ';'], stdout=PIPE, stderr=PIPE)
output, error = proc.communicate()
Error: doesn't list any files.
Usage#2
proc = subprocess.Popen(['/usr/bin/find', '/path/to/dir', '-type', 'f', '-name', '"*.gradle"', '-exec', 'grep', '"KEYWORD"', '{}', '/dev/null', '\\;'], stdout=PIPE, stderr=PIPE)
output, error = proc.communicate()
Error: find: -exec: no terminating ";" or "+"
Usage#3
proc = subprocess.Popen(['/usr/bin/find', '/path/to/dir', '-type', 'f', '-name', '"*.gradle"', '-exec', 'grep', '"KEYWORD"', '{}', '/dev/null', '\;'], stdout=PIPE, stderr=PIPE)
output, error = proc.communicate()
Error: find: -exec: no terminating ";" or "+"
I could get the command working with the shell=True option. However, would like to avoid it as a best practice.
Command works fine when run from the shell.
/usr/bin/find /path/to/dir -type f -name "*.gradle" -exec grep "KEYWORD" {} /dev/null \;
Python Version : 2.7.11
OS X 10.11.3
Appreciate any pointers on how to get this working.
Popenstring?