Executing a Python script from Drupal I'm trying to execute a python script from Drupal using this:



exec('/usr/bin/python name_of_the_script.py')


But it does not work. Although, if I'm on the php console (php -a), then it works fine.

The name_of_the_script.py file has all the permissions.

I thought maybe it was the python command that didn't have all the permissions.

So I checked it with this command:

which python
ls -lisa /usr/bin/python



  694 0 lrwxrwxrwx 1 root root 9 2011-03-09 18:41 /usr/bin/python -> python2.6


Similarly I also used this command:

ls -lisa /usr/bin/python2.6



  369 2240 -rwxr-xr-x 1 root root 2288240 2010-04-16 10:06 /usr/bin/python2.6


It seems everything is OK.

Do you have any suggestions?
Adding 2>&amp;1

exec('/usr/bin/python script.py 2&gt;&amp;1');


Pointed me to the right direction. 

I was writting in a file ( inside the script that hadn't enough permissions )

chmod 666 name_of_the_file.txt totally solved the issue!

Thanks!