看板 Python 關於我們 聯絡資訊
dingyuchi:suid 475510/17 20:29
感謝 還在等網管連絡 我試著比較ls和自己寫一個小py檔 用Popen去跑跑看 程式碼短短的 像下面這樣 #!/usr/local/bin/python import os import cgitb from subprocess import Popen,PIPE cgitb.enable() print "Content-type: text/html\n\n" print "in lstest.py, the uid is %d, the gid is %d" % (os.getuid(), os.getgid()) com=Popen("writesth.py",stdout=PIPE) com.wait() print com.stdout.readlines() 結果顯示有錯 http://kitty.2y.idv.tw/cgi-bin/cgiwrap/~arton36/Psipred/lstest.py 但如果 com=Popen("writesth.py",stdout=PIPE) 這行 改成 com=Popen("ls", stdout=PIPE) 卻又正常抓到ls的結果 請問這是什麼原因呢? (下面是writesth.py檔 沒有寫檔 只有print) #!/usr/local/bin/python import os print "in writesth.py, the uid is %d, the gid is %d" % (os.getuid(), os.getgid()) ※ 引述《Arton0306 (Ar藤)》之銘言: : 我原本有支程式其中有下面兩行 : runAlign=Popen("runpsipred_single "+fileallname, shell=True) : runAlign.wait() : runpsipred_single是一個script小程式 : 在freebsd下執行的 : 原本這樣寫是可以跑的 (會產生一個輸出檔) : 但當我把程式改成從網頁執行時(用cgiwrap)就不能跑了 : 沒產生輸出檔 但這兩行不會有錯誤通知 : 不知用cgi時 Popen是不是需要改變成什麼樣子?? : ==================================================================== : 我在想會不會是shell的關系 : 所以把shell拿掉 不過被擋住了 以下是錯誤訊息 : Traceback (most recent call last): : File "test1.py", line 12, in <module> : runAlign=Popen("runpsipred_single spg", stdout=open("stdout.txt","w")) : File "/usr/local/lib/python2.5/subprocess.py", line 594, in __init__ : errread, errwrite) : File "/usr/local/lib/python2.5/subprocess.py", line 1097, in _execute_child : raise child_exception : OSError: [Errno 13] Permission denied : 因為主機不是我管的 不知這樣要請網管開啟什麼權限呢? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.135.140.149
buganini:./runpsipred_single ? 10/24 00:52
Arton0306:(._.) ...可以了!!! 感謝呀!!! orz 10/24 01:19