我使用'exec'调用函数并将参数定义为变量。在$jsonrequest = escapeshellarg(json_encode($request, JSON_NUMERIC_CHECK));
$solveroutput = exec('sudo python /var/www/website.com/services/run.py $jsonrequest');
我已经试过这样打过电话:
^{pr2}$
以及$solveroutput = exec("sudo python /var/www/website.com/services/run.py $jsonrequest");
也没有“sudo”
当我在服务器(AWS)的命令行中直接调用函数时,我收到的结果如下所示。^上面的{}正是我在命令行中键入的方式。在[lsenna@ip ~]$ sudo python /var/www/website.com/services/run.py '{"max_split":4,"order":681,"max_cost_frac":0.1,"items":[{"productid":8745,"qty":1,"estimatedprice":53.6}],"bids":[{"vendorid":1,"minimum_order":0,"items":[{"productid":8745,"qty":1,"estimatedprice":100}]}]}'
回应:{"status": "OK", "order": 681, "deliveries": [{"vendorid": 1, "productid": 8745}]}
谢谢!在