Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #7207

Re: How to run ".nb" file always in dos command line

From A Retey <awnl@gmx-topmail.de>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: How to run ".nb" file always in dos command line
Date 2011-12-14 11:10 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jca07d$a3q$1@smc.vnet.net> (permalink)
References <jc4pan$cfa$1@smc.vnet.net> <jc7aui$p27$1@smc.vnet.net>

Show all headers | View raw


Hi,

> You can evaluate your notebook from the command line with a
> procedure such as this.
>
> Assuming your working directory is C:\temp\plot demo
>
> create a text file C:\temp\plot demo\runplot.m containing this:
>
>
> Needs["JLink`"];
> $FrontEndLaunchCommand = "Mathematica.exe";
> UseFrontEnd[
> selected = Select[Notebooks[],
>     CurrentValue[#, NotebookFileName] === "1.nb"&];
> If[selected != {},
>   targetnotebook = First@selected;
>   SelectionMove[targetnotebook, All, Notebook];
>   SelectionEvaluate[targetnotebook];
>   ];
> Exit[]];

While I think the above should work, for version 8 it probably can be 
achieved somewhat simpler with something along these lines:

UsingFrontEnd[
  NotebookEvaluate[NotebookOpen["full/path/to/file.nb"]]
]

UsingFrontEnd was new in version 7 and seems to replace UseFrontEnd from 
the JLink-Package without the need to explicitly load a package and 
NotebookEvaluate is new in version 8 and has some additional options 
with which one can control the details of the evaluation. See the 
documentation for the three functions for more information...


hth,

albert

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

How to run ".nb" file always in dos command line wch <weichanghe2000@gmail.com> - 2011-12-12 11:42 +0000
  Re: How to run ".nb" file always in dos command line Chris Degnen <degnen@cwgsy.net> - 2011-12-13 10:55 +0000
    Re: How to run ".nb" file always in dos command line A Retey <awnl@gmx-topmail.de> - 2011-12-14 11:10 +0000
    Re: How to run ".nb" file always in dos command line wch <weichanghe2000@gmail.com> - 2011-12-15 09:56 +0000

csiph-web