Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Run a package from the command line without launching a notebook?

4 views
Skip to first unread message

Garapata

unread,
Aug 11, 2010, 4:46:30 AM8/11/10
to
Hi everyone,

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

Garapata

unread,
Aug 12, 2010, 5:27:08 AM8/12/10
to
Hi again,

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.

Armand Tamzarian

unread,
Aug 12, 2010, 5:31:45 AM8/12/10
to
0 new messages