I'm using batch files to run Mathematica notebooks (with saved output) but in version 10.4 the functionality has changed. Any ideas how to get it working?
I use a batch file to run a .m script which runs a notebook.
(The batch file waits 12 seconds before closing the kernel and the script give the notebook 5 seconds to execute. Temp files could be used to check completion instead.)
runProcess.bat
@echo off
setlocal
PATH = C:\Program Files\Wolfram Research\Mathematica\7.0\;%PATH%
echo Launching MathKernel
start MathKernel -noprompt -initfile "C:\myPath\runProcess.m"
ping localhost -n 12 > nul
echo Terminating MathKernel
tskill MathKernel
endlocal
runProcess.m
Needs["JLink`"];
$FrontEndLaunchCommand="Mathematica.exe";
UseFrontEnd[
file = "C:\\myPath\\Process.nb";
targetnotebook = NotebookOpen[file, Visible -> True];
SelectionMove[targetnotebook, All, Notebook];
SelectionEvaluate[targetnotebook];
];
Pause[5];
CloseFrontEnd[];
Process.nb (3 separate cells)
a = 1;
b = 2;
c = 3;
Plot[{a E^x, b E^x, c E^x}, {x, 0, 1}]
NotebookSave[]
This method has the convenience that notebooks written for manual running can be run automatically, without any conversion for scripting. The plot output and any error messages are simply saved in the notebook.
However, when the batch file is adapted for version 10.4 with
PATH = C:\Program Files\Wolfram Research\Mathematica\10.4\;%PATH%
the kernel just says
FrontEndObject::notavail: A front end is not available; certain operations require a front end.
Comments
Post a Comment