Re: writing mathematica script files for the math kernel under linux
- To: mathgroup at smc.vnet.net
- Subject: [mg25135] Re: writing mathematica script files for the math kernel under linux
- From: Phlip <phlip_cpp at my-deja.com>
- Date: Sun, 10 Sep 2000 03:14:53 -0400 (EDT)
- References: <email@example.com>
- Sender: owner-wri-mathgroup at wolfram.com
Ryan VanRiper (--) wrote: > Hello, I spoke with a tech support person at wolfram and they said > mathematica supported scripting. However he didnt know anything more > then that. Here's the story. Real programming languages let you enter the name of the language, then either a file name or a bit of expression, on a command line: > python spam.py > bash configure > perl -e '/(%^*$% bla bla bla' Mathematica supports a distributed hotline to the kernel called "MathLink". This works in either "add internal function" mode or "replace front end" mode. To get there from here, you must write a thin front end that then passes your script in. E-search for a project called 'mash.c', meaning "MAthematica Script Host". This attempts to give you the scripting front end. However, the resulting system has three flaws. First, 'mash.c' has just enough Linux-isms in it to make anyone on any other platform (or a different Linux install) feel uncomfortable. That's a far cry from "unportable", but /Caveat Emptor/. Second, the program uses MLOpenString() to bond with the kernel. However, one undocumented feature of this function is you must delimit the filename of the location of the kernel using single quotes ' not double quotes ". 'mash.c' uses the former, and MLOpenString() can't use it, gives up, and opens an Open File dialog to ask you to go looking for it. (The presence of this path in your program leads to another problem - without searching for the program in your own code, you must hard-code the location of MathKernel.exe in this string.) Finally, remember when I said real languages could accept a line of source code on the command line? So far as I can tell you cannot use MathLink to just send a string in and get it evaluated. It seems to only deal with language primitives: Functions and symbols and stuff. (I have a post on this group on that subject). If true, this means you are constrained to write your string into a .m file, and then instruct the kernel to Get this. I'm currently using the similar tweak for Python, PYML. You'l probably be fine with 'mash.c' on your Linux. But I can't understand why so powerful and flexible a package should require such ridiculous hacks to beat the simple use-case of "scripting" out of it. -- Phlip ======= http://users.deltanet.com/~tegan/home.html ======= Sent via Deja.com http://www.deja.com/ Before you buy.