On 27/08/13 11:33, Nitish Kunder wrote:
I have a python program which i am calling from a php script.
How are you executing the PHP script? Which OS? Which web server? Which browser? Have you tried others?
The arguments to the program is a path to the file The program when directly run from console executes normally.
So the script itself is fine.
But when I try to execute the program from browser ie call the python script from php, os.system command is not working what might be the problem.
It may be that the browser is not allowed to execute system commands (I hope not since that would be a huge security issue!) But I suspect you are actually running this from a webserver not a browser - that's the usual PHP environment. The webserver runs PHP which renders up HTML out to the browser. In that case the os.system call will try to run on the web server. But it will be running under the webserver account which, again for good reason, may not be permitted to execute system commands.
Other than that its hard to say anything since you don't tell us what os.system() is trying to execute nor what "not working" means.
Finally remember that os.system() does not give you any access to data output by the command, you only get the exit code returned. You will need to use the subprocess module if you want to use the output of the system command (eg to send it to the browser to display).
-- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor