Executing python commands from php script -


I have installed SymPi in the server and from the command line, I was able to execute it I have the following.

  dragon ./sympy-0.7.5/bin/isympy   

(This will open a console where I can type mathematical expressions

  1 + 2   

(will give 3 as output)

My purpose is to do php using shell_exec . I have written one of the following PHP files, but it is not working. $ command = escapeshellcmd ('Python ./sympy-0.7.5/bin/isympy'); shell_exec ($ command); $ output = shell_xac ('1 + 2');

Help in understanding Why is it not working?

Please note that the following script works fine which executes only a python script and retrieves the output.

  $ command = escapeshellcmd ('Python C: \ Pythonprograms \ test3 py'); $ output = shell_xac ($ command); $ echo output;    

My guess is that shell_exec is different from that person when you manually Do the execution.

Your work example specifies a hard path that will work from anywhere. Whereas your non-working example specifies a relative path ( ./ cwd).

Disk to give full path to change your call to isympy . Or understand how to set cwd for shell_exec .

(If this does not resolve it, then say more than "Not working." What happens? An error? What is the full text of the error?)

Comments

Popular posts from this blog

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -

jasper reports - How to center align barcode using jasperreports and barcode4j -

django - CommandError: You must set settings.ALLOWED_HOSTS if DEBUG is False -