MathGroup Archive 2010

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

Search the Archive

Re: Running Mathematica code using DOS

  • To: mathgroup at smc.vnet.net
  • Subject: [mg108714] Re: Running Mathematica code using DOS
  • From: Zach Bjornson <bjornson at mit.edu>
  • Date: Mon, 29 Mar 2010 05:20:39 -0500 (EST)

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
>
>


  • Prev by Date: Re: Transformation of 3D Objects to 2D Parallel-projection
  • Next by Date: Re: Mathematica starts badly 1 time over 5 in OSX
  • Previous by thread: Re: Running Mathematica code using DOS
  • Next by thread: Re: Running Mathematica code using DOS