Running python script from php

2019-02-19 19:00发布

I am trying to run a python script from php.

exec("../cgi-bin/form.py", $output);
var_dump($output);

I'm certain the path is correct, and that form.py is executable.

this is form.py

#!/usr/bin/env python
print "IN form.py'

However, this prints out NULL. I don't think the script is being executed. How do I make sure it is?

标签: php python web cgi
1条回答
The star\"
2楼-- · 2019-02-19 19:36

You're literally just typing in the location of the file. You need to tell exec to execute python with that script.

exec("python ../cgi-bin/form.py", $output);
查看更多
登录 后发表回答