0

这是我的 php 文件中有问题的行:

$eventid_arg = $_REQUEST['eventid'];
$pyresponse_str = system('python s_scrape.py $eventid_arg', $retval);

我为 s_scrape.py 做了以下工作:

1- placed it in the same localhost folder as the php file. 
2- chown changed to www-data:www-data
3- chmod changed to 777 on both the .py and .pyc
4- made sure '#!/usr/bin/env python' is on the python file
4

2 回答 2

1

我可能有点偏离这里,但也许:

$pyresponse_str = system('python s_scrape.py $eventid_arg', $retval);

只需要双引号来识别 $eventid_arg 吗?

$pyresponse_str = system("python s_scrape.py $eventid_arg", $retval);
于 2014-06-17T00:43:18.830 回答
0

只有当 python 没有返回输出时,才应该使用system() 。如果您打算使用标准输入或标准输出,您应该使用popen() 。

正如popen()文档所指出的,这“返回一个与 fopen() 返回的文件指针相同的文件指针,除了它是单向的(只能用于读取或写入)并且必须用 pclose() 关闭。”

于 2014-06-17T00:39:26.073 回答