-1

I am trying to host a website running on php calling a python script on web server.

The web server name (Host) is heroku.com whenever I try to execute my python script with php it does not work (execute).

I think the code itself is little much wrong.

below is the php code for calling python file - forphp.py

$command = escapeshellcmd('forphp.py');
$py = shell_exec($command);
Peyman Mohamadpour
  • 17,954
  • 24
  • 89
  • 100
Jobin 07
  • 21
  • 4
  • 1
    Did you see this post: https://stackoverflow.com/a/19736494/6512170? Btw your question is really hard to read without any punctuation. – Andreas May 28 '20 at 10:36
  • sorry I will add the punctuation's right now. – Jobin 07 May 28 '20 at 10:39
  • And the link that you gave I have already tried it out. – Jobin 07 May 28 '20 at 10:40
  • 1
    What is the error message? – Joao Vitorino May 28 '20 at 13:57
  • @JoaoVitorino I am doing it in web host - heroku.com it does not shows any error message, but the python file is not been executed because if it would have it would have surely showed the output on the php page that I executed on and I have also echoed its output ,But it shows none. – Jobin 07 May 29 '20 at 05:14

1 Answers1

0

you almost have it

$cmd = "python forphp.py"
shell_exec($cmd);
Mike Volmar
  • 1,927
  • 1
  • 22
  • 31