| 1 | Makefile | 2007-01-03 17:42:47 | 1,162 bytes | Rename | Delete |
| 2 | MathIO.m | 2003-06-20 20:13:55 | 1,017 bytes | Rename | Delete |
| 3 | README | 2008-08-28 20:01:31 | 2,814 bytes | Rename | Delete |
| 4 | mash.c | 2006-03-31 18:57:55 | 14,748 bytes | Rename | Delete |
| 5 | mash.pl | 2008-10-14 03:48:50 | 4,750 bytes | Rename | Delete |
| 6 | shuffle.m | 2008-08-28 20:32:56 | 1,086 bytes | Rename | Delete |
| 7 | test.txt | 2001-04-18 14:06:47 | 15 bytes | Rename | Delete |
Daniel Reeves
http://ai.eecs.umich.edu/people/dreeves/mash/
MASH: Mathematica Scripting Hack
(The name refers to the fact that the Mathematica kernel ought to
support this, but doesn't yet...)
This is a prototype of how "math -script" should work.
This works the same way the perl executable does:
* it takes a mathematica source file as its first argument
(or from stdin if no arguments),
* makes all the arguments available to the mathematica code as an
array (list) called ARGV,
* evaluates the code,
* prints to stdout and stderr only what it is explicitly told to.
The advantages of this include having a self-contained mathematica
program that can be executed (with arguments) from the command line,
and be used with other programs in a pipeline, etc.
NOTE: As of Mathematica 6, the C program is no longer needed, though the
dream of math -script is not yet quite realized. But mash.pl is now
all you need.
Original notes on the C version follow:
This is not possible with the "math < infile > outfile" method because
stdin is not available, unwanted stuff gets sent to stdout, and
command line arguments aren't (conveniently) available.
NOTE: see TODO's in the code for discussions of known problems,
future enhancements, etc.
In this directory is the source file (mash.c) and the makefile,
as well as 2 executables, one for Solaris and one for Linux.
To build MASH, edit the Makefile and mash.c where indicated by
"EDIT HERE". Then type make all
For an illustrative example, see shuffle.m in this directory.
The 2 special things about it are
1) the first line is something like #!/path/to/mash
2) it assumes that the list ARGV has been set to the command line
arguments that the program was called with (which mash does).
Also, note that, like using mathematica in batch mode, you need to
have a plain file of just mathematica expressions -- not a notebook file.
To turn a notebook into a plain ".m" file, click on each cell that
you want included in the ".m" file and choose from the Cell menu:
Properties -> Initialization Cell. Then when you save it should ask if
you want to automatically create a package corresponding to the
notebook. Say yes, and the ".m" file that's created can be used with
mash like so:
mash file.m
or
mash file.m arg1 arg2 ...
If you make sure that the first line of file.m is #!/path/to/mash
and make file.m executable then you can just do:
file.m
or
file.m arg1 arg2 ...
MASH can also be used to achieve the functionality of webMathematica
by allowing a Mathematica program to implement CGI or be invoked easily
from any programming language using a system() call.
For example, see http://ai.eecs.umich.edu/people/dreeves/simplify/
