Jump to content

[SOLVED] php function to read local python script output, not code


Recommended Posts

Hi all,

 

On my server python has to run in the wwwroot/cgi-bin folder, but php can run anywhere. My site is going to be written in python but I don’t want my user to see the url as mysite/cgi-bin/... .

 

So for example my homepage, index.php should contain a simple php script that will get my python page from the cgi-bin directory and display it.

 

However when I try to use SSI or fopen/file_get_contents/readlink and commands like these it just displays the python code. Where as when I visit the python page in my browser it runs it and displays the output for me.

 

My question is what php function can I use to execute my python page and return the output, not the code itself. (I think my hosting provider has disallowed certain powerful commands like system() etc. Does this make it impossible?).

 

As the very least can’t my php script pretend to be a www user and ‘visit’ the python page to read the output?

 

Many thanks.

why not just use .htacess mods to rewrite it so no one can really know whats happening

 

That did cross my mind, but I wan't sure if it was possible on a shared server. But a .htaccess file is of course placed in the directory concerned so I guess that would indeed be the best way of doing it.

 

Thanks for pointing it out!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.