[問題] CGI問題
最近開始實作把一些程式webcgi化卻發生了很大的一個問題
#!/usr/local/bin/python
#encoding:utf-8
import time,math,os,re,string,cgi,cgitb
form=cgi.FieldStorage()
accode = form.getvalue('accode')
pwd = form.getvalue('pwd')
filename = accode + ".html"
f=open(filename,"w+")
若不加f=open(filename,"w+") 則可以正常運作
一加後變成
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to
complete your request.
Please contact the server administrator,webmaster@localhost and inform them of
the time the error occurred,and any thing you might have done that may have caused the error.
More information about this error may be available in the server error log.
我看了一下error log
它上面寫
Traceback (most recent call last):
File "usr/lib/cgi-bin/GetDataCgi.py", line 420, in <module>
main()
File "usr/lib/cgi-bin/GetDataCgi.py", line 391 in main
f=open(filename , "w+")
IOError: [Errno 13] Permission denied: 'test.html'
[error] [client 127.0.0.1] Premature end of script headers: GetDataCgi.py,
referer: http:127.0.0.1/menu.htm
[error] [client 127.0.0.1] File does not exist: /var/www/favicon.ico
但我的cgi執行權限有改成755啊...
還是我還有什麼需要改的?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 203.70.89.89
→
05/04 16:20, , 1F
05/04 16:20, 1F
test.html是創出來的
所以原本是沒有的......
不過我不知道怎麼創出來後權限直接改755?
→
05/04 16:28, , 2F
05/04 16:28, 2F
我也在想是不是這個問題,但這要怎麼著手下去?
推
05/04 20:40, , 3F
05/04 20:40, 3F
!!!可以了!~原來要把目錄的執行權開啟
推
05/05 11:00, , 4F
05/05 11:00, 4F
是的~
不過現在的問題是~~要怎麼把我創出來的test.html自動改權限成755......
有辦法在創建這檔案時就自動設成權限755這樣嗎?!
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
最後我用subprocess處理掉了
但底下還沒想到.....
還有另一個問題就是我要怎麼.py執行完後網頁自動導向test.html啊?
※ 編輯: elvisteal 來自: 203.70.89.89 (05/05 15:43)
※ 編輯: elvisteal 來自: 203.70.89.89 (05/05 16:00)
推
05/05 19:20, , 5F
05/05 19:20, 5F
→
05/05 19:20, , 6F
05/05 19:20, 6F
→
05/05 19:20, , 7F
05/05 19:20, 7F