axiom-developer
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Axiom-developer] RE: Axiom Session


From: Bill Page
Subject: [Axiom-developer] RE: Axiom Session
Date: Mon, 21 Aug 2006 01:27:59 -0400

On August 18, 2006 11:58 PM Alfredo Portes wrote:

> In http://toolbox1.sytes.net/~alfredo/axiomui/
>
> is any way to keep the Axiom session open in a server side
> script.
>
> With this I mean, when I call axiom, I open a FILE stream and
> call certain functions in Axiom and get the result like this:
>
> In perl, I am doing something like this:
>
> open (FILE, "| /usr/bin/AXIOMsys >/tmp/axiom");
> print FILE ")set output tex on\n"; 
> print FILE ")set output algebra off\n";
> print FILE ")set message autoload off\n";
> print FILE ")set message type off\n";
> print FILE $question;
>
> however after the script finishes, the session too. So if you
> input a command after it doesn't know about the previous
> calculation, like you can do inside Sage.

The main problem here I think is that you seem to be trying to do
this using a simple cgi script in Apache?

Normally the Apache web server processes cgi requests in a stateless
manner, i.e. it starts a process, collects output and stops the
process on each request and doesn't remember anything from one call
to the next. To do something more sophisticated you will have to use
a different technique on the server side that permits a processes to
persist. See for example:

http://en.wikipedia.org/wiki/Mod_perl
http://en.wikipedia.org/wiki/Mod_python

Another possibility is instead of using Apache, you could use a web
application server such as Zope or even PHP. Zope for example would
allow you to write methods in Python that communicate with an external
process and return results via xmlhttp.

> Is there a way to do this in python??? or any other language?

Yes, certainly. Besides established a web application server
environment the 2nd problem you have to solve is the communication
between Mod_perl/Mod_python/Zope and Axiom. To do this, I think your
best option here is to use a package such as pexpect

http://pexpect.sourceforge.net

(in python). There is something similar for perl

http://sourceforge.net/projects/expectperl
http://sourceforge.net/docman/display_doc.php?docid=9977&group_id=6894#descr
iption

but I haven't used it.

Pexpect starts some external process and uses the pseudo terminal (pty)
interface to send and receive commands and output to and from it.

For example Sage uses a version of pexpect to communicate with Maxima.

In the near future I intend to convert MathAction to using pexpect
instead of pipes (similar to what you describe above) because there
are problems with pipes as soon as you try to call processes that
communicate with other processes such as the way in which 'sman'
starts 'AXIOMsys' and a separate Axiom graphics process. The pty
interface solves this sort of problem because it interacts with
the processes at the level of the virtual serial pty device.

Regards,
Bill Page.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]