Question

I want to do something like that in php (running on apache2):

require("somecgi.py")

where somecgi.py is a python file with a valid shebang. My apache is configured to execute the cgi-script when opened directly in brower. But i can't bring php to recognize the script as a cgi-script and instead inserts the source code of the script. For campatibility with text based browsers i don't want to use frames. I googled about that problem and found that there is a configuration option cgi.check_shebang_line. I think this could be related to that, but i'm also very new to php and don't kno where to set this option.

My OS: linuxmint KDE 14 (Kubuntu 12.10 derivate)

Was it helpful?

Solution

Read up on require / include. It will execute php code, not python code. In order to execute the python code you will need to run a shell_exec type command from php, which should execute the python code like you would call it from the shell.

The gist, the include / require options are used for including php files to be parsed by the php engine. Including random files with commands that are not php will attempt to parse the file using the php engine.

EDIT

If the shell_exec is not what you are looking for, maybe a redirect is or you may have to elaborate on your question to get down to what you really need.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top