Matlab via the WWW -- Mocha
Introduction
We have developed a procedure for using Matlab and a browser together
as clients for graphical applications. The browser can
- Download Matlab programs from the server and start the Matlab
process
- Control the process, including substituting information from HTML
forms into Matlab's command stream
- Shut down the Matlab window
This software provides a Matlab analogue to Java, allowing us to take
advantage of all of Matlab's computational and graphical
capability. It will work with Mosaic as well as Netscape, but does
require a UNIX system. Following Tom's suggestion, we shall call the
software Mocha.
However, the security of the software has not been thoroughly
tested. (I have heard of security holes in Java, too, and people
suggest you only look at Java applets from known sources.) Not many
people know about Mocha at the moment, so that's some help. In
addition, you could install it to run as "nobody" (as outlined in the
installation notes) which stops a lot of potential problems, since the
Matlab code will not have write permission on your own
directory. Causes other problems, though - it's hard to get rid of
processes if you forget to Quit, and, for some applications, one might
want to run scripts as well (which requires real trust). Finally, the
best procedure is probably to enable the software only when you plan
to look at specific trusted material and disable it afterwards. The
procedure is described below.
Principles
The Mocha software is a program, mq, which can accept
information from the WWW in much the same way as Ghostscript, xv, or
another "helper" external viewer. It works with the MIME type
application/x-matlabqueue. The program recognizes various
commands in the data stream and can save files in
/tmp/mocha-$USER, begin a slave Matlab process, pass Matlab
command lines to the process (using a named pipe), remove the files,
and terminate the subprocess.

Installation
There are various approaches to installation: We shall discuss here
the case when someone on your cluster already has the software
installed. You need that user's name. On geosys, it's
ecosys, while on the 14/15 floor machines, it's
glenn and on the 16/17th floor it's lab. In the
instructions below, replace owner by this user's name. If no
one in your cluster has Mocha, you need to install it using the
procedure found here.
- Setup: (this is done once by each user - before starting a
browser) Type
- ~owner/mocha/install
- Enabling Mocha: (this can be done in another window while a browser
is running) When you wish to view a Mocha procedure, type
- ~owner/mocha/enable
- Disabling Mocha: (likewise) When you are done, type
- ~owner/mocha/disable
- Note: Before disabling, you should have quit your Mocha
process, so that the
Matlab window has gone away; otherwise, you may have a stray process
and the working area in /tmp hanging queue around. If you forgot, you
can get rid of these by either
- Load the browser and page back in and hit the Stop
Matlab button
- Or, if that does not work,
rm -r /tmp/mocha-$USER
Look for mq, matlabqueue or Matlab processes
and kill them.
Example:
Once you've gone through the installation, you can test things out by
enabling the software and clicking the following links in order:
which should download /tmp/test.m, /tmp/test2.m and
start Matlab.