Reputation: 73
i want to run a python script from php code using exec or shell_exec. this is php code :
<?php
exec('/usr/bin/python /var/www/html/test.py');
?>
also this is the python script i want to execute it from browser, name test.py :
#!/usr/bin/env python
import os
f= open("/var/www/html/result","w")
f.write("ok")
script runs from command line correctly, but when i execut it from browser , it dose not work. I searched a lot of things and i did following items to solve the problem :
But still the script dose not work when i visit http://server_ip_address/home.php . I'm new in php and apache. can anybody help me to solve the problem. great thanks
Upvotes: 0
Views: 494
Reputation: 11
Can you try
<?php
exec('/usr/bin/python3 /var/www/html/test.py');
?>
and
#!/usr/bin/env python3
import os
f= open("/var/www/html/result","w")
f.write("ok")
Upvotes: 1