2011-03-03 90 views
0

與php exec命令等價的mod_python是什麼?相當於php exec()命令的mod_python

$cmd = '/var/www/scripts/test.py' + $parameter 
$return = exec($cmd) 

我已經試過,但它不返回任何

varReturn= subprocess.check_output(['/var/www/scripts/resolveID.py ', varParameters) 

回答

1

捕獲子進程的輸出和錯誤:

from subprocess import Popen, PIPE 

proc = Popen(['/var/www/scripts/resolveId.py', 'arg1', 'arg2'], stdout=PIPE, stderr=PIPE) 
stdout, stderr = proc.communicate()