Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Evaluate a Mathematica Notebook from Applescript (e.g. every morning)

  • To: mathgroup at
  • Subject: [mg112509] Re: Evaluate a Mathematica Notebook from Applescript (e.g. every morning)
  • From: Guido Tripaldi <guido at>
  • Date: Sat, 18 Sep 2010 07:24:08 -0400 (EDT)

One solution is to "cron" your nb file. Cron is the Unix scheduler that automatically execute at the specified time/date the commands as specified in its /etc/crontab file (a "command" can be the filepath of your nb). There is a useful program for mac in the public domain, written by Sven Schmidt, that offer a graphical mac-like interface to easy manage the scheduler:

To let Mathematica run your code on notebook startup, you have to make your nb file "auto executable" first, otherwise cron will launch the nb, but Mathematica will open it in the editor without executing it. To do that you have to:
- define in your "auto execute" notebook an "initialization Cell" which contain the code you want to evaluate automatically;
- configure the notebook to don't display the initialization warning dialog during its opening;
- configure Mathematica front end to don't display the initialization warning dialog during notebooks auto initialization.

here is a simple example. Suppose you want to automatically display the current date and time calling the function DateList[] every time your "auto execute" notebook will be opened:

1 - type DateList[] in a cell, then got to the menu "Cell -> Cell Properties -> Initialization Cell" to let the cell auto evaluate on startup;

2 - type and evaluate these lines in another cell of the same notebook:

 InitializationCellWarning -> False,
 InitializationCellEvaluation -> True]

SetOptions[ $FrontEnd, InitializationCellWarning -> False ]

(after evalutating them you can delete the two SetOptions instructions from the notebook)

3 - save your notebook: Mathematica will ask if you really want to create an AutoSave package (of course say yes).

4 - done.

Now you can test your auto execute notebook, and configure the cron scheduler appropriately.

Please note that the SetOptions[ $FrontEnd, InitializationCellWarning -> False ] will disable the warning messages permanently, be careful: by disabling this warning messages you compromise the security of Mathematica environment, please read the tutorial "tutorial/NotebookSecurity" in the documentation center.


Il giorno 17/set/2010, alle ore 12.41, perdalum at ha scritto:

> Hi there!
> I'm trying to create a small Mathematica Notebook that should run e.g.
> every morning at 0800. As I'm on a Mac, my first choice is to do this
> by using iCal to call an Applescript the evaluates the Notebook.
> But I cannot get Applescript to evaluate a notebook and I cannot find
> any examples on using Applescript or Automator. I know that Rob
> Schofield has written an Automator thing, but it is not Universal and
> wont run on my Snow Leopard MacBook.
> I have looked almost everywhere without any luck.
> Any ideas?
> Regards,
> perdalum

Guido Tripaldi

  • Prev by Date: Re: Map Correlation[] across sublists of matrices
  • Next by Date: Re: A little help with sort
  • Previous by thread: Evaluate a Mathematica Notebook from Applescript (e.g. every morning)
  • Next by thread: Solving differential equations?