mod_python equivalent to php exec() command

 ̄綄美尐妖づ 提交于 2020-02-06 12:48:11

问题


what is the mod_python equivalent to the php exec command?

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

I've tried this but it doesn't return anything

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

回答1:


Capture the stdout and stderr of the subprocess:

from subprocess import Popen, PIPE

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


来源:https://stackoverflow.com/questions/5185958/mod-python-equivalent-to-php-exec-command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!