通过PHP运行Python脚本

It is a follow-up a question to my earlier post.

I have developed a chat program using twisted in Python. I would like to integrate into a PHP script and be able to run through the browser.

The chat program would open a HTML window.

I could run it using PHP5 command in the terminal and is working fine. However, when I call the PHP script through the browser it does not work.

Any idea what is missing.

EDIT : I am not getting any error on the browser, however, the python script is not running ,

Here is my PHP code :

$unique_no = 1234;
$unique_name = "Kiran";

$command = '/usr/bin/python /var/www/php_program/chat.py ' . $unique_no  . ' ' . $unique_name ;

shell_exec($command);

Thanks Kiran

This doesn't make sense. The PHP script runs on the web server. It generates some output which gets sent to the web browser. Then the interaction is over until the web browser issues a new request.

You won't be able to run a Python chat program in a web browser by writing a PHP program that runs the Python program. The Python program presumably needs to get input (for example, what message does the user want to send to the chat session?) and it can't do that when you're running it like this.

To develop a web-based chat system, the chat application actually needs to be aware that it's going to run in a browser.

Take a look at the Nevow chat tutorial for one example of how you might go about developing this application.