0

I asked a question here earlier and got a few useful responses. But when I try to run a python script from php, I get a NULL return. I doubt it's a permissions issue since I ran chmod 777 on my working directories for testing purposes to rule that out and I still get the same issue. I tried looking online for an answer but from what I could find, people either have an issue running as well as their command, or no issue at all.

Why does exec() and shell_exec() work with ls on my webpage, but not with my python script?

Eric F
  • 1
  • 2
  • Do your python scripts have a correct shebang? – Arkadiusz Drabczyk Dec 23 '20 at 19:49
  • I did some research and added `#!usr/bin/env python3` as well as `#!usr/bin/python` to the python file I am trying to run and am getting the same results. What would be the correct way of going about adding a shebang? – Eric F Dec 23 '20 at 20:15
  • The shebang you added is incorrect, `#!/usr/bin/env python3` is correct – Arkadiusz Drabczyk Dec 23 '20 at 20:16
  • Fixed that, still returning NULL – Eric F Dec 23 '20 at 20:58
  • Hi Eric, If you happen to see this comment someday, do you think it might have to do with needing to specify the full path to python when running a Python script from PHP? Something like this: `exec('/full/path/to/python /path/to/script.py', $output);`? This thought is based on [this previous comment](https://stackoverflow.com/questions/66365728/how-to-include-imports-and-trigger-a-python-script-from-php#comment117475029_66365728) and [this comment](https://stackoverflow.com/questions/66404529/crontab-via-exec-not-working-with-php-7-4-deb-10/66406082#comment117396094_66404529). – summea Mar 03 '21 at 02:58

0 Answers0