I'm using Python to call cscope
internally. For this I'm using subprocess.call
.
The problem is that it's not working without shell=True
The following code works as expected:
import subprocess
subprocess.call("cscope -d -L0'temp'", shell=True)
But the following doesn't, it returns with 0
status code, but there is no output
import subprocess
subprocess.call(["cscope", "-d", "-L0'temp'"])
Any ideas as to why the above is happening?
Don't quote the arguments, the args are passed directly to the process without using the shell when shell=False:
subprocess.call(["cscope", "-d", "-L0","temp"])
You should use check_call:
from subprocess import check_call
check_call(["cscope", "-d", "-L0", "temp"])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.