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')
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。