【发布时间】:2013-12-14 02:34:50
【问题描述】:
我有一个 bash 脚本,它可以帮助建立一个本地 SimpleHTTPServer。
python -m SimpleHTTPServer 8080
我已将它放在我的项目文件夹中。当我使用以下方式运行程序时:
subprocess.call('./setup.sh')
出现错误消息:
Traceback (most recent call last):
File "test.py", line 2, in <module>
subprocess.call('./setup.sh')
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 522, in call
return Popen(*popenargs, **kwargs).wait()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 709, in __init__
errread, errwrite)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1326, in _execute_child
raise child_exception
OSError: [Errno 13] Permission denied
我在终端重试了这个
localhost:Desktop XXXX$ sh setup.sh
Serving HTTP on 0.0.0.0 port 8080 ...
它工作正常。 我记得有几次终端弹出一个窗口,询问我有关防火墙的python权限,我允许了。你能帮帮我吗?
【问题讨论】:
-
您可能需要在
setup.sh上设置可执行位。 -
以 root 身份运行 (sudo)
标签: python bash simplehttpserver