linux - Processing file paths with parentheses with Python subprocess -
the paths of files want process contain parentheses in them.
path = "/dir/file (with parentheses).txt"
i'm trying process them in python follows:
subprocess.call("./process %s" % path, shell=true)
however, following error
/bin/sh: 1: syntax error: "(" unexpected
how can pass correct string process proper path?
try this
subprocess.call('./process "%s"' % path, shell=true)
i guess problem more space in file name. file names spaces in them should enclosed in quotes ./process "foo bar.txt"
or escaped ./process foo\ bar.txt
.
Comments
Post a Comment