作者starskgb (Metal)
看板perl
標題[問題] 不知從何debug起
時間Mon Jun 18 22:22:08 2007
這是一個接收cookie資料用的程式碼
-----------------------------------------------------------------
#!c:\perl\bin\perl.exe
import os
import sys
import cgi
import datetime
if __name__ == "__main__":
log=[]
log.append(str(datetime.datetime.today()))
# get the cookie from url?c=asdf
form = cgi.FieldStorage()
if form.has_key("c"):
log.append(form["c"].value)
else:
log.append()
# get some request info
log.append(str(os.environ['REMOTE_ADDR']))
log.append(str(os.environ['HTTP_REFERER']))
log.append(str(os.environ['HTTP_USER_AGENT']))
# save the log array
f = os.open("cookielog.txt",os.O_APPEND|os.O_WRONLY)
os.write(f,",".join(log)+"\r\n")
os.close(f)
# write response
sys.stdout.write("Content-Type: image/gif\r\n\r\n")
pixel = os.open("../images/pixel.gif",os.O_RDONLY)
sys.stdout.write(os.read(pixel,1000))
os.close(pixel)
sys.stdout.flush()
-------------------------------------------------
因為我沒學過perl,這是網路上找到的sample code
當我的cgi server要接受資料執行到這隻程式時server的log檔就出現一堆錯誤了
為了研究cookie資料可以被人用到何種程度而需要用到這程式
希望有人能幫我debug~~感激不盡
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.123.107.6
※ 編輯: starskgb 來自: 140.123.107.6 (06/18 22:23)
1F:→ DarkKiller:這明明是 python code... 06/18 23:44
2F:推 imce:我...怎麼覺得這個不是perl寫的,有點像.....java 06/18 23:44
3F:→ jlovet:python...... 06/19 00:01
4F:推 LiloHuang:.py 06/19 02:02
5F:→ qrtt1:python, perl 傻傻分不清楚 :P 06/19 02:14
6F:推 starskgb:囧興,因為檔名是cgi,我對這類語言完全外行=.=" 06/19 03:12
7F:→ starskgb:那要讓它在網頁上跑,還是用perl.exe嗎??code第一行 06/19 03:16
8F:→ starskgb:我是用appserv+activeperl 06/19 03:17
9F:推 LiloHuang:你需要裝ActivePython 然後副檔名改.py 06/19 03:51
10F:→ starskgb:可以work了,感謝 06/19 17:41