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!
Guest Geoff Posted May 9, 2011 Posted May 9, 2011 You're just outputting to the browser what you normally would to the console.
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?
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").
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.
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