Hi.. i just download a script that do a task which is lets say
If i execute this at my server
wget '127.0.0.1:64652/v12345567' , i am able to use my python script and download the file.
but now i want make a php script which do the following
it will make my server execute 127.0.0.1:64652/v12345567 and return the result that is create by my default.py and provide the link by Echo "<a href='$resultreturn'>Download File</a>"
anyone can tell me how i can do it.
basically i need my server to execute the command , i try use my server ip to do the execute + port but it dont work..
e.g http://myserverip:64652/v12345567 , it return error lander.. page not found or something . this is weird haha though myserverip should be same as my that 127.0.0.1
Thanks a lot for your help
How to use php execute server command and return result
Moderator: General Moderators
- vargadanis
- Forum Contributor
- Posts: 158
- Joined: Sun Jun 01, 2008 3:48 am
- Contact:
Re: How to use php execute server command and return result
Hi!
What you need is the exec() or exec_shell() function. They are easy to use! Look it up on php.net.
Just a comment: why do u mix python and PHP? U can pretty much do everything with PHP what u can do with Python. Even OO.
Another option that just came to me is executing the python as a CGI script (need to set up Apache for that) and use fopen(). This is a little bit more complicated but can be very effective.
If u need to run that python script as root ud better look up su module for Apache. DANGEROUS!
What you need is the exec() or exec_shell() function. They are easy to use! Look it up on php.net.
Just a comment: why do u mix python and PHP? U can pretty much do everything with PHP what u can do with Python. Even OO.
Another option that just came to me is executing the python as a CGI script (need to set up Apache for that) and use fopen(). This is a little bit more complicated but can be very effective.
If u need to run that python script as root ud better look up su module for Apache. DANGEROUS!