我有一個bash腳本,它可以幫助建立本地的SimpleHTTPServer
。Python運行bash腳本並生成OSError
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'上的可變位。 – devnull
以root身份運行它(sudo) – Dan