I run Mathematica on a Mac (Snow Leopard).
I need to run a package from the command line without launching a
notebook.
First, I created a notebook with four cells:
Needs["myPackages`myPackage`"]
connectionInfo = {"databaseDriver", "databaseLocation", "username",
password"};
workFlow[connectionInfo];
Quit[]
All pretty simple:
Needs[] loads a package that I've placed in an ExtraPackages
subdirectory.
connectionInfo gives database connection parameters.
workFlow[] runs some code and writes to the data base.
Quit[] should exit the kernel
This all works fine running in a notebook.
I took the notebook, made each cell an initialization cell, and saved
it as a package,
"myAutoRun.m"
I researched the documentation, the internet, and this forum and found
that MathKernel should start the Mathematica Kernel on Mac OS X
But now I don't know what I need to do in the terminal window to
launch the kernel and run the package.
I don't know my way around a terminal window or command prompt, so I'd
appreciate as explicit instructions as possible (especially defining
file paths and changing directories if I need to do so).
Thanks everyone,
G
I just found out how to do this. The required syntax for the command
line looks something like this:
/Applications/Mathematica.app/Contents/MacOS/MathKernel -run "<</
Path.../myAutoRun.m"
Works perfectly.
Thanks to all anyway.
Still the best forum I know about on the internet!
G.