Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

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

Search the Archive

Re: Executing a Notebook and saving the modified Notebook - all without the GUI

  • To: mathgroup at smc.vnet.net
  • Subject: [mg125141] Re: Executing a Notebook and saving the modified Notebook - all without the GUI
  • From: A Retey <awnl at gmx-topmail.de>
  • Date: Fri, 24 Feb 2012 00:57:14 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com

Am 23.02.2012 11:47, schrieb C. Mundi:
> Surely there is a "simple" way to tell Mathematica from the command
> line to run a notebook and save the state of the notebook!  We would
> have hoped for something like "mathematica.exe --nogui --notebook
> Test.nb" would work, especially if we embedded something like
> "NotebookSave[]; End[];" at the end of the file.
>
> We've been searching for an answer to this question for days, and none
> of the answers we've found actually solves our problem.  So before you
> answer, please read my question, which I will try to make very clear
> with a very simple example at the risk of seeming pedantic.
>
> Given a Notebook file, Test.nb with a single cell
>
>      In[1]:= Plot[Cos[x], {x, 0, 2 Pi}]
>
> we can open the Notebook in the front end, Evaluate the (whole)
> Notebook and get the expected Out which is a plot of a single cycle.
> We now save the notebook, using the GUI menus.  We then open Test.nb
> in the front end and we see both the input expression and the output
> plot saved previously.  Good.
>
> Now we want to do everything *without* the GUI.  Let our INPUT be the
> original Test.nb file, i.e. inputs but no outputs yet.  Let our RESULT
> be a modified Test.nb including the plot.  We seek a sequence of batch-
> like commands which will transform our INPUT into our RESULT, viz.
> with no GUI interaction and in fact under the control of an external
> unix shell script.  It is permissible for the script to cause
> mathematica to access files besides Test.nb.
>
> We need the output to be in NB form, because we need the embedded
> graphics.  But we also need to evaluate the notebook in an automated,
> unattended way.
>
> At this time, solutions based on MathLink are not attractive to us.
>
> We have looked at FrontEndToken but have not yet found a way to effect
> the result we seek.  We also note that some of the interesting
> FrontEndTokens -- particularly those related to Evaluate -- come with
> warnings that they are not yet fully integrated into the long-term
> plan for Mathematica.  That sounds ominous.

No need to refer to FrontEndTokens for this. You should be able to write 
a script that would be run by the kernel with using
UsingFrontEnd, NotebookOpen, NotebookEvaluate, NotebookSave. I have not 
time to actually try that but I don't think it would be very difficult 
to achieve. See the documentation for details, for NotebookEvaluate you 
will need to set InsertResults -> True.

hth,

albert




  • Prev by Date: Re: Kolmogorov Smirnov in two or more dimensions is in Mathematica 8.0.4
  • Next by Date: Re: simplifying algebraic expressions with Null
  • Previous by thread: Executing a Notebook and saving the modified Notebook - all without the GUI
  • Next by thread: Re: Executing a Notebook and saving the modified Notebook - all without the GUI