[OS Shell] how to run python compiler from php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
elnaz1010
Forum Newbie
Posts: 12
Joined: Sun Mar 28, 2010 10:28 pm

[OS Shell] how to run python compiler from php

Post by elnaz1010 »

the title is self expeditionary,
how to run python compiler from php?
something like:
echo passthru('python test.py') won't to the job.
i tested it with exec or shell_exec or system, but still i get no result, just a null output.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: [OS Shell] how to run python compiler from php

Post by Christopher »

Is it actually running python? You may need absolute paths? When you say not output, are you getting a result array and error code back from exec() ?
(#10850)
elnaz1010
Forum Newbie
Posts: 12
Joined: Sun Mar 28, 2010 10:28 pm

Re: [OS Shell] how to run python compiler from php

Post by elnaz1010 »

yes it build a process in host OS and will execute test.py

there is no need to have absolute path, if python is installed, it is in path, so that you can call it anywhere. test.py is beside php script, so that there is no need to have absolute path. and no i get a null value with exec without any error code in it :(

all i want to do is to run a process in my host, so that it can do some automatic job with out user request. so again, how i can access my python compiler from php and get some output?
and by the way i want my scripts to be runnable in as much as hosts as possible, am i should go for pure c or c++ and then compile it? or using python is fine and most hosts have them?
also tell me if perl compiler is more available in hosts than python.

thanks alot
regards, elnaz
Post Reply