8.5 Can cmaple run in a server mode? (10.11.00)

8.5.1 Carl Eberhart
8.5.2 Theodore Kolokolnikov (14.11.00)
8.5.3 Theodore Kolokolnikov (14.11.00)
8.5.4 Greg Nash (17.11.00)
8.5.5 Andre Poenitz (27.11.00)

8.5.1 Carl Eberhart

Is there a version of command line maple which runs in a server mode? That is, it can be started up and accept input from and return output to other applications, such as a Perl script? None of the command line options to cmaple (in Maple 6) suggest that this is the case, but perhaps not all options are listed.

8.5.2 Theodore Kolokolnikov (14.11.00)

Yes. By default cmaple reads from standard input and writes to standard output.

Use also -q option. We have successfully used cmaple as an engine for over-the-web evaluation of math tests.

See also my answer on

http://www-math.math.rwth-aachen.de/MapleAnswers/735.html

which also contains a Java class to interact with Maple.

8.5.3 Theodore Kolokolnikov (14.11.00)

Try the following example. It illustrates how to send commands from Maple to Perl, and retrieve calculations and graphics.

#!/usr/local/bin/perl 
#get the current process number 
$pid = $$; 
#open a connection to Maple 
$maple = "| cmaple -q  > maple.$pid"; 
$maplegif = "maplegif.$pid"; 
open(MAPLE, $maple) || print STDERR "Maple can't be opened!\n"; 
#Send commands via print 
print MAPLE "evalf(Pi); \n"; 
print MAPLE "interface(plotdevice=gif,plotoutput=`$maplegif`, 
                       plotoptions=`width=500,height=300`);\n"; 
print MAPLE "plot(x^2, x=-2..2);"; 
print MAPLE "quit;\n"; 
close(MAPLE);
 

8.5.4 Greg Nash (17.11.00)

I’m not quite sure I understand your question, but I have run cmaple in a cgi directory from a perl script on a remote server.

From my web browser, using forms to enter data/procedures, I ran cmaple on the server using this input and returned results that got displayed in my browser.

I set up the script to allow me to download output files as well by clicking on a button.

If you want any more details let me know, but it was very straightforward.

8.5.5 Andre Poenitz (27.11.00)

You can pipe a command into maple as grab the output as you would do with every other command:

~ > echo -e "result:\n `echo 'int(x,x);' | maple -q`"
 

result:

                                           2 
                                     1/2 x
 

The -q supresses the "banner" at startup.