Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

Re: Batch Mode Return Code by WindowsDavid Bailey,

  • To: mathgroup at
  • Subject: [mg64245] Re: Batch Mode Return Code by WindowsDavid Bailey,
  • From: David Bailey <dave at>
  • Date: Wed, 8 Feb 2006 03:53:32 -0500 (EST)
  • References: <ds1rt1$fli$>
  • Sender: owner-wri-mathgroup at

LectorZ wrote:
> Hi guys,
> I created a package.m which I run in a batch with a runmybatch.bat.
> The package.m contains a bunch of initialization cells. Every cell does
> a calculation to be executed.
> The output is a graph.jpg
> I schedule my bat file to be run twice a day.
> Question:
> How can I configure the batch file so that if at least one cell in
> package.m returns an error, math.exe returns ONE and if every cell in
> package.m has been executed without an error - then math.exe returns
> I need this to automaticly control the execution of the Mathematica
> jobs.
> Many thanks!
> LZ
I tested Quit[n] and although it closes the MathKernel session, the 
integer error code did not seem to be transmitted back to the command 
shell. However, since you are generating a file, why not erase this and 
test to see if the file exists (from within the batch file) after the 
Mathematica code has run.

This leaves the matter of ensuring that if any of your commands generate 
an error they exit early rather than just struggling on and generating a 
plot file anyway. If you wrap commands that might fail in Check you can 
specify the action to be taken if an error occurs -


However, it is probably better to isolate known problems explicitly - 
for example, test to see if an input file exists, rather than just 
waiting for the mistake to cause an error.

David Bailey

  • Prev by Date: Re: Defining a derivative that distributes for a function
  • Next by Date: Re: Defining a derivative that distributes for a function
  • Previous by thread: Re: Re: DSolve:: Bessel's differential equation
  • Next by thread: Number-Theory :: All-Digit Perfect Squares