Message Boards Message Boards


Batch capacities of Mathematica?

Posted 3 years ago
6 Replies
1 Total Likes

Dear all,

I am working on windows 7 or 8. I try the batch capacities of Mathematica. I have written a very simple notebook


Export["essai.txt", N[Sin[2]]]


and I have typeset

MathKernel -script essai1.m > essai.out

MathKernel -run "<<essai1.m" > essai.out

math -run essai1.m > essai.out

I have also tried

math < essai1.m > essai1.out &

with the following result

*Mathematica 10.0 for Microsoft Windows (64-bit)
Copyright 1988-2014 Wolfram Research, Inc.
In[2]:= In[2]:= 
In[7]:= In[7]:= In[7]:= In[7]:=* 

Whichever be the command there is no output. We would like to generate may files with export in jpeg, png or eps but we know not how to do.

Is there some one who could help ?


6 Replies
Posted 3 years ago

In Win7 64

On my desktop I create a text file file named mbat.bat of one line containing exactly

"C:\Program Files\Wolfram Research\Mathematica\10.0\math" < "C:\Users\bill\desktop\in.txt" > "C:\Users\bill\desktop\out.txt"

On my desktop I create a text file file named in.txt of one line containing exactly

Export["g1.jpg", Plot[x^2,{x,-3,3}]]

When I double left click the mbat.bat file on the desktop it creates files named out.txt and g1.jpg on my desktop and the second file is an image of the plot.

Can you reproduce exactly this, only changing the user name?

Dear Bill,

Thanks for the answer it seems to work perfectly well. I wonder only why this is not documented.

Posted 3 years ago

I am very happy that it worked for you.

You can try making one tiny change at a time to get closer and closer to what you originally had. Test each small change and see if it still works. For example you might be able to change "C:\Users\bill\desktop\in.txt" to just in.txt. You might be able to change "C:\Program Files\Wolfram Research\Mathematica\10.0\math" to just math. Try to determine the simplest set of steps that works for you. Perhaps you will discover what caused your problem in this way.

Someone wrote there are at least a dozen different ways of doing anything in Mathematica. It is perhaps very difficult to document something in Mathematica in a way that every user will quickly and easily understand how to use a feature.

I recommend everyone create a small Mathematica notebook on their desktop. Each time you discover how to get something to work that you might need in the future you append a new cell to your desktop notebook with a good title and your own documentation for the few lines of code that worked. This becomes your own personal help system.

Hi Bill I am also doing similar thing like running Mathematica script from a bat file, and running it from a Task scheduler. I tried your above example, it works fine when I double click the mbat.bat file, both "out" and "jpg" files are generated, however when I run it from Task scheduler, only "out" file is generated, "jpg" file is not generated. Is there any problem with Mathematica to export graph files from Task scheduler.

Initially I tried to run the *.m file directly from the Task scheduler, it didn't work so I am trying your method I am using windows 10. Please help, Thanking you


Posted 3 months ago

The example provided exports the expression to essai.txt

Export["essai.txt", N[Sin[2]]]

but tries to executes essai.m

MathKernel -script essai1.m > essai.out

Hi I wanted to run Mathmetica script from windows task scheduler, so I created two files, Test.nb file containing the Mathematica code to export a graph like below

resultChart = JuliaSetPlot[0.365 - 0.37 I];
Export["C:\\Dev\\test.png", resultChart];

Solve.m file to run the above notebook like below

$FrontEndLaunchCommand = 
  "C:\\Program Files\\Wolfram \

UsingFrontEnd[Module[{}, file = "C:\\Dev\\TestPng.nb";
   targetnotebook = NotebookOpen[file, Visible -> True];
   SelectionMove[targetnotebook, Next, Cell];


Created a task in windows 10, task scheduler

enter image description here However when I run this task, I cannot see any graph exported to C:\dev folder

What am I doing wrong here, I cannot see any errors when I manually run Solve.m or Test.nb file in Mathematica?

Can you please help.

Thanks. Nalina

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract