Reputation: 1067
Is there any special permission or setting in order to execute a python script that create a new file or image? This is my code:
<?
function py(){
exec( 'python my_script.py');
echo "ok";
}
py();
?>
And this is my python script (an example):
#!/usr/bin/python
import sys
f = open('out.txt', 'w')
print >> f, 'thats all'
f.close()
Running php i get "ok" message but no file is created. What am i doing wrong?
Upvotes: 4
Views: 1985
Reputation: 361
You need to call shell_exec()
not exec()
if you want to be able to capture the output:
Upvotes: 0
Reputation: 1067
Setting the right permissions to file and folders did the trick.
On Mac OS: Alt + Click on "+", then search for _www and add World Wide Web Server to users giving read and write permission. Same for the root folder.
Upvotes: 1