0

I know a lot about python but I don't know all the aspect to php would it be possible to run python and have it out put code to php then to nginx and then to the client. Now I do realize that this is somewhat counter productive (so please do not post about how this is a bad idea) but I was just curious if this was possible at all...?

gabeio
  • 1,282
  • 1
  • 23
  • 37
  • 2
    yes. `exec`. but that's all i know. – Cole Tobin Jun 28 '12 at 03:25
  • Oh wow yeah python could run the code through php wow duh :] thanks! – gabeio Jun 28 '12 at 03:26
  • 1
    Check this : http://stackoverflow.com/questions/166944/calling-python-in-php – yoda Jun 28 '12 at 03:30
  • @yoda that is actually the exact opposite of what I wanted ahaha thanks to Cole I remembered php can be called from command line (with python) – gabeio Jun 28 '12 at 03:34
  • 1
    This sounds like a web service to me. Have you considered spitting values out of PHP as JSON and then sending the JSON to Python to NGINX etc. - http://wiki.python.org/moin/WebServices. This would also allow you to sanitize the output from one to another. – Aaron Newton Jun 28 '12 at 05:17
  • I had not considered that good idea :] – gabeio Jun 28 '12 at 06:16

1 Answers1

0

Thanks to Cole Johnson I remembered that you can just call php after writing to the dynamic.php file and retrieving the output using subprocess then send the returned code to nginx to the client (yes this may be about twice the time) but if you are looking for a super secure way of running php code this might be an idea. Have python parse the code before running it so all calls that are not "in legal" legal being a list will be commented out or returned as an error.

Community
  • 1
  • 1
gabeio
  • 1,282
  • 1
  • 23
  • 37