I’m trying to execute a py file from php.
here is my code:
//usage python my.py var1 var2
$libre = 'python ../../../../root/py/my.py '.$var1.' '.$var2.'';
$cleanlibre = escapeshellarg($libre);
echo exec($cleanlibre);
What is wrong?
Why is it returning nothing?
I also need to know how to secure exec well. Thanks.
–edit–
Used passthru
$libre = 'python ../../../../root/py/mech.py '.$var1.' '.$var2.'';
$cleanlibre = escapeshellarg($libre);
passthru($cleanlibre, $result);
echo $result;
//returned 127 <- i don't know where thats from.
escapeshellargshall only be used to escape the arguments, not the whole command.