从php运行python脚本 [英] Running python script from php

查看:69
本文介绍了从php运行python脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从php运行python脚本。

I am trying to run a python script from php.

exec("../cgi-bin/form.py", $output);
var_dump($output);

我确定路径是正确的,并且form.py是可执行的。

I'm certain the path is correct, and that form.py is executable.

这是form.py

#!/usr/bin/env python
print "IN form.py'

但是,此打印为NULL。我不会

However, this prints out NULL. I don't think the script is being executed. How do I make sure it is?

推荐答案

您实际上是在输入脚本的位置该文件。您需要告诉exec使用该脚本执行python。

You're literally just typing in the location of the file. You need to tell exec to execute python with that script.

exec("python ../cgi-bin/form.py", $output);

这篇关于从php运行python脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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