【发布时间】:2014-02-25 16:47:52
【问题描述】:
我有一个通常使用 Cygwin 执行的 bash 文件。 我需要从我的 Python 代码中运行这个文件。
我试过了:
for bashfile in files:
p = Popen(bashfile, cwd=dname) #dname is the current directory of the script
stdout, stderr = p.communicate()
我也看到了类似的问题here,但是当尝试以这种方式运行它时,它说它找不到我的 bash 文件的目录...
有什么想法吗?谢谢! :-)
编辑:bashfile 有完整路径。
【问题讨论】:
-
你的脚本在哪里,你的 bash 文件在哪里?
-
bash 文件位于脚本目录的子目录之一中。关键是他们在不同的地方。有关系吗?
-
如果
bashfile只是脚本的名称(例如foo.sh),请尝试指定脚本的路径..../subdir/foo.sh。 -
能否提供完整的错误信息?