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! Quote
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. Quote
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? Quote
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! 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.