Mathematica Sample Batch File

mathematica.xml
 
<?xml version="1.0" ?>
<!-- Sample XML Job File -->
<job>
<nodes>1</nodes>
<minutes>20</minutes>
<type>batch</type>
<affiliation>serial</affiliation>
<run>\\tc.cornell.edu\tc\users\your_userid\mathematica\mathematica.bat</run>
</job>
 
mathematica.bat
 
REM --- Call setup file for Mathematica
call setup_mathematica.bat
 
REM --- Users must set ROOTDIR, OUTDIR, IN_FILE and OUT_FILE variables.
set ROOTDIR=\\tc.cornell.edu\tc\users\%USERNAME%\mathematica
set OUTDIR=%ROOTDIR%\output
mkdir %OUTDIR%
set IN_FILE=test.m
set OUT_FILE=test.out
 
REM --- Create temp directory, clean up any pre-existing out_file(s),
REM --- and copy input file(s) from ROOTDIR.
del /Q T:\%USERNAME%
mkdir T:\%USERNAME%
cd /D T:\%USERNAME%
del /S /Q T:\%USERNAME%\*.*
copy %ROOTDIR%\%IN_FILE% T:\%USERNAME%\
 
REM --- Execute Mathematica and run your script file
math.exe < %IN_FILE% > %OUT_FILE%
 
REM --- Copy the T: files back to the output directory
copy /y T:\%USERNAME%\%OUT_FILE% %OUTDIR%\
 
REM --- Clean up files from this job
cd /D T:\
rd /s /q T:\%USERNAME%
 
vsched -c