I have the following code in a .m file which is called test.m:
Export["test.csv",0]; Exit[]
I would like to run this .m file from the command line. I found that I can do that with the command "math -initfile test.m". It seems to work, but when I check out the produced .csv file (it does get produced), I find that it's empty (so does not contain 0). When I run the .m file using the GUI it produces the .csv file with 0.
Anyone know how I can get this working from the command line?
Thanks
Import
andExport
for many formats are among them. This is why usingmath < tst.m
as suggested will usually work. There are even better ways to run mathematica scripts from the command line for newer versions, search the docs (or this site) for mathematica and script to learn more... $\endgroup$ – Albert Retey Dec 9 '14 at 11:43