0

I have a PHP program, and a Python program. You can think that the Python program is like a robot or machine. Typically, it will use a database, do some analysis and return result for you. It is a plain text console application.

I would like to let the user use the program via a web interface. So, I would like to use PHP, accept user input, and the pass it to the Python program, and back to the user.

How can I achieve it? The Python program is always running on the server, which will keep analysis data from the web and the user input, so it can't easily convert to become a script on server side.

Any ideas?

Adam Lear
  • 38,111
  • 12
  • 81
  • 101
DNB5brims
  • 29,344
  • 50
  • 131
  • 195
  • 1
    Please use the search, you will find many questions here how to launch a process from PHP with parameters and get the text output of that process. – hakre Dec 30 '11 at 16:09
  • 2
    Look at [`system`](http://php.net/manual/en/function.system.php), [`exec`](http://php.net/manual/en/function.exec.php), or [`proc_open`](http://php.net/manual/en/function.proc-open.php), depending on what you need to do. –  Dec 30 '11 at 16:11
  • http://www.php.net/manual/en/ref.exec.php These are the functions on php-doc. I never know which one’s for what ;) – aufziehvogel Dec 30 '11 at 16:11

2 Answers2

2

You might want to check exec function. You can pass the input from user as parameters to the python script and get back the output from it.

osoner
  • 2,425
  • 1
  • 15
  • 13
0

Take a look into http://www.csh.rit.edu/~jon/projects/pip/

Bruna
  • 366
  • 2
  • 15