import subprocess
cmd = "grep -r * | grep jquery"
print cmd
subprocess.check_output(cmd, shell=True)
subprocess.CalledProcessError: Command 'grep -r * | grep jquery' returned non-zero exit status 1
I can execute that command in my shell without issues. How can I see the actual error in python?
The snippet is part of a larger script which takes multiple arguments and chains the grep commands + adds some excludes (I don't need to grep log files or minified JavaScript. Hence the pedantic syntax.
Python 2.7.10
grepdoes if your match fails. - larsksgrep -r jquery .? - idjawgrep -r *looks for the name of the first file in your directory inside all the other files in your directory. I can't conceive of under what circumstances that would be correct behavior. - Charles Duffygrep -r jquery .- kev