subprocess.call(["/home/blah/trunk/blah/run.sh","/tmp/ad_xml","/tmp/video_xml"])
我这样做但是,在我的run.sh中,我有“相对”路径.
所以,我必须“cd”到该目录,然后运行shell脚本.我怎么做?
最佳答案
使用cwd参数subprocess.call()
来自这里的文档:http://docs.python.org/library/subprocess.html
If
cwd
is not None,the child’s
current directory will be changed to
cwd
before it is executed. Note that
this directory is not considered when
searching the executable,so you can’t
specify the program’s path relative to
cwd
.
例:
subprocess.call(["/home/blah/trunk/blah/run.sh","/tmp/video_xml"],cwd='/tmp')