Maxima use with php -
i try use function shell_exec() or system() execute maxima scripts php. example:
<?php chdir("c:\program files (x86)\maxima-sbcl-5.35.1.2\bin"); $cmd = "maxima"; $res = exec($cmd,$out,$status); echo "out="; print_r($out); echo "res=".$res.php_eol; echo "status=".$status.php_eol;` ?>
output:
out=array ( [0] => maxima 5.35.1.2 http://maxima.sourceforge.net [1] => using lisp sbcl 1.2.7 [2] => distributed under gnu public license. see file copying. [3] => dedicated memory of william schelter. [4] => function bug_report() provides bug reporting information. [5] => (%i1) ) res=(%i1) status=0
in match "(%i1)_" have run script "solve(x^2-1=0, x)";
but it's not recognized cmd script.
you’re trying run maxima in interactive mode, i.e. start command shell , interactively enter expressions , results in return.
what need non-interactive mode. according maxima’s man page, there 2 ways work in non-interactive mode: --batch
, --batch-string
(also, --batch-lisp
, that’s not relevant here).
the first method expects pass file name expressions processed. second method allows define string command line.
in example, should invoke maxima following:
$expr = escapeshellarg("solve(x^2-1=0, x)"); $cmd = "maxima --batch-string=$expr"; // … , on
if want more complex calculations, should dump them temporary file , pass file location maxima via --batch
parameter.
Comments
Post a Comment