i have a php file which have some variables para1 and para2 , i want to send them to a python file . this is my php file:
<?php
$para1 = "one";
$para2 = "two";
echo "shell_exec("
/C:/xampp/htdocs/Ai_Edutech_trial_project/eclipse_workspace/Project
/check.py '$para1' '$para2'")";
?>
and this is my py file:
import sys
x=sys.argv[1]
y=sys.argv[2]
print(x)
print(y)
but this does not work for me. Can someone please help me with this or suggest some other way?
Don't put quotes around the function call. That turns it into a literal string, not a call to the function. Windows pathnames don't use a /
before the drive letter, so the path should start with C:
. And there shouldn't be a space after Project
.
echo shell_exec("C:/xampp/htdocs/Ai_Edutech_trial_project/eclipse_workspace/Project/check.py '$para1' '$para2'");
Also, if you're just going to echo the result, you can use the passthru
function instead.