I have a python script which executes the following line
os.system('mysql -H -uusername -ppwd -hipaddr -e"some query" >filename.html')
when this python script is executed independently everything seems fine, a html file is generated with the query output.
But when i call the python script from php(using shell_exec()) ,there occurs a problem."filename.html" is created but the file is empty.When is searched regarding this i found this has to be done
setsebool -P httpd_can_network_connect=1.
As a result now i can connect to mysql using mysqldb module in python script called from php, which i am not in need of. I want to execute query using execute command of mysql through os.system() which is still a problem when called from php. Is there any suggestions so that i can get it right?
Edit : here is my php script
<?php
$command = escapeshellcmd('python csv_generate.py');
$output = shell_exec($command);
echo $output;
?>
here is my python script (csv_generate.py)
import sys
import os
print "hii"
query="show databases"
os.system('mysql -H -uaaa -pbbb -hhostip -P3306 -e"%s" >filename.html'%(query))
When called from php ,python script gets executed and it prints hii. The html file is also created but the file is empty .Even when i try to display the output in the browser i.e,
os.system('mysql -H -uaaa -pbbb -hhostip -P3306 -e"%s"'%(query))
it justs prints only "hii"
the error log contains
sh: /usr/local/mysql/bin/mysql: Permission denied