0

I am trying to use php exec() function to execute a python file. When i try something like this:

echo exec("python app.py");

It works but if i omit the python string and keep it like this:

echo exec("app.py"),

it gives this error: Syntax error: word unexpected (expecting ")")" which also shows up even if i change from python to another language other than php like JavaScript

app.py only contains one code line: print("Hello World").

What am i doing wrong please as this is my first time using the exec() function.

1 Answers1

0
  1. app.py should include a Shebang so it will look like this:
#!/usr/bin/python
print("Hello World")
  1. echo exec("./app.py")

Hope this works and helps!

~ PanTrakX

PanTrakX
  • 71
  • 1
  • 3