Deep Thought Posted May 7, 2011 Posted May 7, 2011 I've used Python and PHP before, but I still have no idea how to start a Python program other than from a command line. Any tips on starting a Python script from PHP? Thanks in advance! Quote
Guest Geoff Posted May 9, 2011 Posted May 9, 2011 You're just outputting to the browser what you normally would to the console. Quote
Deep Thought Posted May 9, 2011 Author Posted May 9, 2011 I can't get the script to start though. Guess I should have posted more info: I have a Python script in /cgi-bin and I can use it directly from there. But I've been trying to start it from a PHP file outside of /cgi-bin, and a few days ago I started searching online for ways to do that. I tried virtual(); that doesn't seem to be set up. Then I tried include() and require(), but that just outputted the text of the file, instead of running the script. file_get_contents does the same thing. Any ideas? Quote
Guest Geoff Posted May 9, 2011 Posted May 9, 2011 This would require doing shell_exec(), but that's disabled for security reasons. What you could do is file_get_contents("http://yoursite.com/cgi-bin/python_script.php"). Quote
Deep Thought Posted May 12, 2011 Author Posted May 12, 2011 Well, that was a quick fix Thanks for the help! Works like a charm. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.