My default Web-Application is based on PHP. However, for easiness, I have built a python script that does some analysis. Now I need the php to call the python code and retrieve the output that the python code delivers. Both files are in the same server, not on the same folder however. My current approach, which does not work, looks as following:
$cmd = "/usr/bin/python /var/www/include/sCrape.py -u '$my_url' ";
$response = shell_exec($cmd);
$response = json_decode($response, true);
Now when I try to print out $response, I get the NULL object (it should return an array-string that I should decode through json_decode). Am I doing something wrong with the function? The php is located within /var/www/html/. The following code works when both files are in the same directory:
$cmd = "python sCrape.py -u '$my_url'";
$response = shell_exec($cmd);
$response = json_decode($response, true);
Further information: my_url is input as a sanitized $_POST variable from php, but I have now tried to completely disable sanitizing to test if it would work, but it still didn't (still, the url's path until it reaches the function is longer, as it must be passed on through form-post, whereas in my same-folder-test-case I have simply just declared $my_url). the -u postfix means that the script inputs a url.
Thank you very much in advance!