valkyrion123 Posted February 8, 2016 Posted February 8, 2016 As the title say i want to run a python script that called using exec command in PHP for example $id = '4552763663200002';$command = 'C:\Python27\python.exe simple.py '. $id; exec($command, $string); but how to do this on heliohost server?can someone help me? Thank you
wolstech Posted February 8, 2016 Posted February 8, 2016 You can't since we disabled exec. The closest I can think of is to write the python script as if it were for a website, then file_get_contents() the script through the web server from php. The output of your python script will end up in the return variable of the file get contents call for you to use in php.
valkyrion123 Posted February 8, 2016 Author Posted February 8, 2016 You can't since we disabled exec. The closest I can think of is to write the python script as if it were for a website, then file_get_contents() the script through the web server from php. The output of your python script will end up in the return variable of the file get contents call for you to use in php. hmm since my scripts is only triggered by some action and also need an input for it, with that method, how did i pass the input to the script? thanks
wolstech Posted February 8, 2016 Posted February 8, 2016 If the python script is written for a web server, it can be made to accept data from POST and GET requests. You'd make a form in HTML to enter the required data, the submitted data is passed via POST to the script, script runs it and returns output. I don't know how to handle POST data in Python though (I'm a PHP programmer). You can likely eliminate the PHP component entirely if you're insistent on using Python. Do you have good reason (other than not wanting to rewrite your code) to use two languages? If it were me, I'd just rewrite the Python tasks in PHP and discard the python components...
valkyrion123 Posted February 9, 2016 Author Posted February 9, 2016 If the python script is written for a web server, it can be made to accept data from POST and GET requests. You'd make a form in HTML to enter the required data, the submitted data is passed via POST to the script, script runs it and returns output. I don't know how to handle POST data in Python though (I'm a PHP programmer). You can likely eliminate the PHP component entirely if you're insistent on using Python. Do you have good reason (other than not wanting to rewrite your code) to use two languages? If it were me, I'd just rewrite the Python tasks in PHP and discard the python components... well my python script do web scraping with form input handling and i don't know how to do that in PHP, also i got another one for image recognition and python is easier also faster and that is why i keep using this script. but since you said python can be made into POST request, i think i can learn one.. Thanks for your help
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now