I have trying to call a python code from bar.php like
$cmd = "python foo.py";
system($cmd);
It runs with no problem. However, foo.py should save a file on disk. And it wasn't there. I somehow figured out that the user running the web server is www-data.
I tried running the php script from command line with user www-data $ php bar.php It runs OK and saved the file, so user www-data should have permission to write to the directory.
I noticed that there is a vote on "would not be helpful to other user". However, when you have a php service and you have code written in other language like python, knowing this is necessary.
Thanks for all suggestions.
I suspect it is b/c I use Matplotlib in the python code in foo.py, I have code like
pl.scatter(data,...)
pl.plot(data,...)
pl.legend()
pl.save('path/to/bam.png')
Maybe when calling from the web, it can draw images. Is that possbile? If so, is there any way to fix it? Thanks!