rodbm Posted August 24, 2019 Posted August 24, 2019 Hey there everyone, I have good knowledge of python but I'm still learning Php (well to be honest I started learning it for this purpose).I have a Python script in /cgi-bin and it works fine when I go to mydomain.heliohost.org/cgi-bin/script.py. What I want to do is make it so that it starts from a Php file outside of /cgi-bin. I tried shell_exec() but I'm getting the "Warning: shell_exec() has been disabled for security reasons..." message. I know this function can be used for malicious purposes and that's why it's blocked.I tried some other functions but nothing seems to work or I'm doing it wrong. Question: Can this be done without the use of shell_exec() by any chance? I know there are some duplicate topics of this subject, but as I said I tried a few solutions posted on them and these didn't work. Thanks for your attention!
wolstech Posted August 24, 2019 Posted August 24, 2019 Assuming the python can be run in a browser by calling it’s URL and it producing browser-compatible output (I.e. http headers, etc.), call it via file_get_contents() using its full public URL. The function will call the script and return the output for further use.
rodbm Posted August 24, 2019 Author Posted August 24, 2019 Thank you wolstech. I tried that before and I still can't get this function to work. The py file I'm using is as follows: #!/usr/bin/python print("Content-Type: text/html\n\n") print("Heliohost rules!") And the php I'm trying to make it to work is as follows:<?php$grab = file_get_contents("http://mydomain.heliohost.org/cgi-bin/test.py");echo $grab;?> I get the message:Warning: file_get_contents(http://mydomain.heliohost.org/cgi-bin/test.py): failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized in ../test.php on line 3 I with the dir path instead of the url but it just returns the full code in plain text.Am I doing something wrong?
rodbm Posted August 24, 2019 Author Posted August 24, 2019 Edit: I fogot I had the directory privacy up for that url. It works perfectly now, thanks!
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