mod_python的等效到PHP EXEC()命令(mod_python equivalent t

2019-11-05 02:50发布

什么是mod_python的等同于PHP的exec命令?

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

我试过,但它不返回任何东西

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

Answer 1:

捕获子进程的输出和错误:

from subprocess import Popen, PIPE

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


文章来源: mod_python equivalent to php exec() command