Sorry about the rather obtuse title to this post but I can't really even describe this bug accurately.
I need to call a python script from php. It requires MySQLdb.
Code:
# pytest.py
print('1')
import MySQLdb
print('2')
PHP Code:
<?php
# apachetest.php
$cmd = "/usr/local/bin/python2.5 /home/sam/www/pytest.py";
echo("The cmd :: $cmd \n");
echo("Output :: \n");
system("$cmd");
On my dev box (Ubuntu) it works fine. The strangeness happens on the production server (Redhat). I can run apachetest.php from the command line fine - '1' & '2' are printed. But if I call (
http://localhost/apachetest.php ) from a webrowser it fails?
So when the apachetest.php gets called by apache it won't import MySQLdb in the python. '1' gets printed but *not* '2'?
I would have thought that the cmd being executed by system( ) would be completely independent of apache?
Anyway I've hit a brick wall - If anybody can shed any light on this for me, I would be very grateful.
Thanks in advance