I am learning how to run a Mathematica m file from command line. I am on windows. My question is: How to make the output display on the screen (the DOS windows) as the script is running? Currently, I have to add Print
to show anything. What I'd like, is that all the OUT cells that normally display in notebook, to print to stdout (I do not care much about the actual OUT[n] itself, but just the content of the output).
Here is a simple example of foo.m
---- file foo.m ----------
Integrate[Sin[x],x]
----- end of file -----------
Now I run this as follows
G:\>"C:\Program Files\Wolfram Research\Mathematica\10.1\math.exe" -script foo.m
G:\>
You can see, nothing is displayed. I tried changing foo.m as follows
---- file foo.m ---------------
SetOptions[ $Output, FormatType -> OutputForm ];
Integrate[Sin[x],x]
--------end of file ---------------
Only when I add an explicit Print
around each command will I see the output.
Is there a setting one needs to add or some trick to have the command output go to stdout?
Windows 7, 64 bit, Mathematica 10.1
For illustration, this is the same thing I do with Maple. In Maple it actually displays all the input and all the output, which is nice, so I hope the same thing can be done in Mathematica.
The file used above contains the same command as with Mathematica:
-----foo.mpl------
int(sin(x),x);
---- end of file -----