Passing Commands To Python From PHP

Go To StackoverFlow.com

2

I have a python script on a vps that I run a simple command though.

./script.py [ipaddress] [portnumber]

example

./script.py 127.0.0.1 8080

What I'd like to do is put a simple php script on my apache server (same vps) with a form on the page to enter the ip address and port number into it.. Along with a go button.

After running the script I'd like it to display the scripts output below. IF possible (as im really just not sure) I'd like to be able to have several people use it at once... example.. 10 users all passing data to the same script at the same time.

My server is running CentOS

2012-04-04 23:28
by Harold Giddings


4

popen() is what you want

http://www.php.net/manual/en/function.popen.php

This allows you to run an arbitrary command and get the stdout result.

2012-04-04 23:30
by John
Thank you very much, I'll look into it and see what I can come up wit - Harold Giddings 2012-04-04 23:46
Ads