From: Maria Davis on
Hi,

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.

From: David Bailey on
Maria Davis wrote:
> Hi,
>
> 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.
>
I assume you don't really mean DOS (which is a very old 16-bit operating
system), but the box you can open using CMD.

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

From: Maria Davis on
Hi David Balley
Thank you very much for your kind response.
I have created the file:"MYFILETOEXECUTE.nb" containing the code to execute.
I have created a new file named: "file.m" containing the following code:

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.

From: Zach Bjornson on
Or, if you need a bit more control or if your system doesn't associate
..nb or .m with Mmeca, you can do something like this:

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

On 3/28/2010 7:56 AM, David Bailey wrote:
> Maria Davis wrote:
>
>> Hi,
>>
>> 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.
>>
>>
> I assume you don't really mean DOS (which is a very old 16-bit operating
> system), but the box you can open using CMD.
>
> 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
>
>

From: dh on
Hi,
if you want to run a program under the kernel without the frontend
interface, you would write your input into a *.m file.
If you want to shutdown mma after the commands are executed, you end
your file with: Quit[]
To launch the Kernel and execute your commands:
....\MathKernel -noprompt -inputfile FileName
If the kernel is not on the Path, you need to give the full name,
enclosing it in quotes if it contains spaces. The same may apply the
input file name.
Daniel

On 28.03.2010 11:07, Maria Davis wrote:
> Hi,
>
> 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.
>


--

Daniel Huber
Metrohm Ltd.
Oberdorfstr. 68
CH-9100 Herisau
Tel. +41 71 353 8585, Fax +41 71 353 8907
E-Mail:<mailto:dh(a)metrohm.com>
Internet:<http://www.metrohm.com>