I'm trying to run python file from PHP
What I'm looking for is :
1- run python file from index.php
2- read the output of python file and show it in index.php
Example :
# test.py
import sys
user = sys.argv[1]
password = sys.argv[2]
def read():
if user == "user@dmoain.tld" and password == "123456":
return "ok, registerd"
else: return "I can\'t"
try: read()
except: pass
And in index.php should be some thing this :
<?php
$read = exec("python test.py user@dmoain.tld 123456");
if($read == "ok, registerd")
{
echo "succesful registerd";
}
else ($read == "I can\'t")
{
echo "failed";
}
?>
I'm not sure what should I do in index.php how can I do it?