I want to run Mathematica with DOS Command. My purpose is to launch
a Mathematica program written in .nb file or in .txt file and to
execute it.
Can you please help me?
Many thanks.
The easiest way to start a notebook or package file from within such a
system, is to type:
start foo.nb
or
start foo.m
(The start command uses the .nb suffix to recognise that the file should
be opened using Mathematica).
You wouldn't write a Mathematica program in a .txt file, but in a .m file.
BTW, I am a great fan of computing from the command line, and using
batch files, etc - which probably reveals something about my age!
However, I use a program called 4NT, which looks just like the standard
CMD box, but has additional features.
David Bailey
http://www.dbaileyconsultancy.co.uk
UsingFrontEnd[
nb = NotebookOpen["MYFILETOEXECUTE.nb"];
SelectionMove[nb, All, Notebook];
FrontEndTokenExecute[nb, "EvaluateCells"];
]
I tried to use the command:
start file.m
But this command opens file.m, and to execute it, I must press the
button "Run Package" .
Is there a command that can execute automatically the package?
Thanks.
MathKernel -noprompt -run "(*some command*);Quit[]"
In cases where you need to execute a file, set all of the cells as
Initialization Cells, then run
MathKernel -noprompt -initfile YourFile.m
where your notebook is normally YourFile.nb. There might be a more
glamorous way of doing that, but that works. (You will probably need to
use explicit/full file paths for both MathKernel and YourFile.)
Cheers,
Zach
--
Daniel Huber
Metrohm Ltd.
Oberdorfstr. 68
CH-9100 Herisau
Tel. +41 71 353 8585, Fax +41 71 353 8907
E-Mail:<mailto:d...@metrohm.com>
Internet:<http://www.metrohm.com>
Hi Maria,
my guess is that mathematica does not find your file. Did you give the
full name, including the path?
cheers, Daniel