tags:

views:

53

answers:

3

Possible Duplicate:
Start local PHP script w/ local Python script

How do you execute a php file and then view the output of it?

os.system("php ./index.php")

Does not work only returns 0

A: 

If you're working under Windows, you can use os.startfile().

Bertolt
Linux is in use here.
JamesM
os.startfile it will not return the output of php to the calling python function.
Rajan
+1  A: 

What you need is the os.popen function. It runs the command and returns the stdout pipe for that commands output. You can also capture the stdin, stderr by using os.popen2, popen3

import os

outp = os.popen('php ./index.php')
text = outp.read() # this will block until php finishes
                   # and returns with all output in text
print text
Rajan
yay this worked.. Thank you lots..
JamesM
You are Welcome! :-)
Rajan
A: 

What sort of out put are you looking for, would that be on a web page or just on the console. You have to give us enough information to help you.

Helen Neely
web page is what i was after.
JamesM