2016-09-08 2 views
1

Dans Windows, démarrez Maxima dans la ligne de commande, tapez ??plot; commande, vous verrez ceci.Comment utiliser PHP et AJAX pour exécuter une commande Maxima (qui doit être saisie de manière interactive) à partir du navigateur Web (localhost)?

alors, vous devez interagir avec la ligne de commande en sélectionnant le order number ou all ou none. Maintenant, je veux utiliser PHP et AJAX pour créer un site Web (localhost), puis lorsque vous accédez au script PHP localhost, vous pouvez interagir avec la ligne de commande Maxima backend pour utiliser la commande ??plot; sur le site Web.

J'écrire un script PHP comme suit:

nom: cmx.php

<?php 
chdir("D:/Program Files/Maxima-5.30.0/bin"); 
$expr = escapeshellarg("display2d:false$ ??plot;"); 
// $expr = escapeshellarg("display2d:false$ solve(x^2-1=0, x);"; 
$cmd_str = "maxima --batch-string=$expr"; 

$res = exec($cmd_str, $out_arr, $return_val); 
$out_str = implode('<br/>', $out_arr); 
echo $out_str.'<br/>'; 
?> 

Cette fois-ci, quand j'accéder http://localhost/cmx.php, le contenu du Web est:

Maxima 5.30.0 http://maxima.sourceforge.net

using Lisp GNU Common Lisp (GCL) GCL 2.6.8 (a.k.a. GCL)

Distributed under the GNU Public License. See the file COPYING.

Dedicated to the memory of William Schelter.

The function bug_report() provides bug reporting information.

(%i1) display2d:false

(%i2) describe("plot",inexact)

0: Functions and Variables for Plotting

1: Gnuplot Options

2: Gnuplot_pipes Format Functions

3: Introduction to Plotting

4: Plotting Formats

5: Plotting Options

6: barsplot (Functions and Variables for statistical graphs)

7: barsplot_description (Functions and Variables for statistical graphs)

8: boxplot (Functions and Variables for statistical graphs)

9: boxplot_description (Functions and Variables for statistical graphs)

10: contour_plot (Functions and Variables for Plotting)

11: get_plot_option (Functions and Variables for Plotting)

12: gnuplot_close (Gnuplot_pipes Format Functions)

13: gnuplot_curve_styles (Gnuplot Options)

14: gnuplot_curve_titles (Gnuplot Options)

15: gnuplot_default_term_command (Gnuplot Options)

16: gnuplot_dumb_term_command (Gnuplot Options)

17: gnuplot_file_name (Functions and Variables for draw)

18: gnuplot_out_file (Gnuplot Options)

19: gnuplot_pm3d (Gnuplot Options)

20: gnuplot_preamble (Gnuplot Options)

21: gnuplot_ps_term_command (Gnuplot Options)

22: gnuplot_replot (Gnuplot_pipes Format Functions)

23: gnuplot_reset (Gnuplot_pipes Format Functions)

24: gnuplot_restart (Gnuplot_pipes Format Functions)

25: gnuplot_start (Gnuplot_pipes Format Functions)

26: gnuplot_term (Gnuplot Options)

27: implicit_plot (Functions and Variables for Plotting)

28: multiplot_mode (Functions and Variables for draw)

29: plot2d (Functions and Variables for Plotting)

30: plot3d (Functions and Variables for Plotting)

31: plotdf (Functions for numerical solution of differential equations)

32: ploteq (Functions for numerical solution of differential equations)

33: plot_format (Plotting Options)

34: plot_options (Functions and Variables for Plotting)

35: plot_realpart (Plotting Options)

36: scatterplot (Functions and Variables for statistical graphs)

37: scatterplot_description (Functions and Variables for statistical graphs)

38: set_plot_option (Functions and Variables for Plotting)

39: starplot (Functions and Variables for statistical graphs)

40: starplot_description (Functions and Variables for statistical graphs)

41: stemplot (Functions and Variables for statistical graphs)

Enter space-separated numbers, 'all' or 'none':

Still waiting:

Maxima encountered a Lisp error:

Error in PROGN [or a callee]: Unexpected end of #.

Automatically continuing.

To enable the Lisp debugger set debugger-hook to nil.

Cependant si $expr = escapeshellarg("display2d:false$ solve(x^2-1=0, x);"; dans le script PHP, je peux obtenir les résultats attendus.

En outre, j'ai vu un problème similaire How to execute an interactive command from PHP?, mais cela ne fonctionne pas pour mon problème.

Alors que je veux continuellement interagir avec la ligne de commande sur le Web, et j'espère que les contextes peuvent être associés les uns aux autres.

Que dois-je faire? Existe-t-il des conseils efficaces ou un cadre Web pour m'aider à mettre en place ce site Web?

Répondre

1

J'ai essayé de comprendre votre question, les ressources qui suivent peuvent être utiles pour vous.

je trouve que, try.redis, web macaulay2, web Singular sont toutes les interfaces Web du logiciel redis, macaulay2 et Singular.

alexmchale/try.redis: Une démonstration de la base de données Redis. https://github.com/alexmchale/try.redis

try redis

GitHub - fhinkel/InteractiveShell: Construire des applications web pour les outils de ligne de commande interactive https://github.com/fhinkel/InteractiveShell

web Macaulay2: http://habanero.math.cornell.edu:3690/ web-macaulay2

web Singulier: https://www.singular.uni-kl.de:8003/ web-Singular

Mais il semble que ces projets opensource ne sont pas implémentés en PHP et AJAX.

+1

Ces ressources sont utiles, mais j'insiste sur l'implémentation de la Webstie en utilisant PHP et AJAX, merci tout de même. – iMath