Re: FrontEnd and bash automatization
- To: mathgroup at smc.vnet.net
- Subject: [mg109638] Re: FrontEnd and bash automatization
- From: David Bailey <dave at removedbailey.co.uk>
- Date: Sun, 9 May 2010 07:50:44 -0400 (EDT)
- References: <hrtvuh$s97$1@smc.vnet.net>
Arturas Acus wrote: > Dear group, > > I have a large collection of notebooks I want to run in Mathematica FrontEnd authomatically. > > math < in > out solution is not applicable, because Notebooks contains commands like NotebookCreate[], etc.. > > I tried JLink solution, something like > Needs["JLink`"]; $FrontEndLaunchCommand="mathematica -matlink -display :1 -nogui"; ConnectToFrontEnd[] > Unfortunatelly, thought I can use commands like Plot*, it do not allow open notebooks in the connected FrontEnd. > > The only way I found to execute notebook in Mathematica FrontEnd authomatically is to set all notebook cells as initialization cells, then > set the following options in the init.m file > > AutoOpenNotebooks->{"/home/acus/test.nb"}, > InitializationCellEvaluation->True, > InitializationCellWarning->False > > But this solution has drawback is that I have to execute different notebooks. Probably it could be solved creating some master notebook, which > consequently opens and executes other notebooks. > > But may be somebody could suggest better way? Thanks in advance. > > > Sincerely, It would be easy to create a script of things you needed to do as a .m file. Such a file is much easier to execute automatically (with Get) and because it is a simple text file, it could even be partially constructed in a bash script. It could also use the Environment[] function for even greater flexibility. The leaves the little matter of starting the whole thing by command. There is a function UseFrontEnd which you can wrap around a sequence of operations that need the FE, and then execute the whole thing as input to Math. I executed the following using Math: UseFrontEnd[ nb=NotebookCreate[]; Print[nb]; ] Obtaining: In[1]:= NotebookObject[<<Untitled-1>>] This may do exactly what you want, but I would caution slightly that this is the sort of area in which Mathematica bugs seem to reside - so test it well with the kind of operation you want to do before committing to it! David Bailey http://www.dbaileyconsultancy.co.uk