mod_python等效于php exec()命令 [英] mod_python equivalent to php exec() command

查看:86
本文介绍了mod_python等效于php exec()命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

mod_python与php exec命令等效吗?

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)

推荐答案

捕获子进程的stdout和stderr:

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()

这篇关于mod_python等效于php exec()命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆