I encounter the problem that I can't save any output from Mathematica script. Here is a minimal example.
test.m
Export["/home/my_home_folder/file.txt", "hello world"]
I run the script with
math -script test.m
and the output file is not produced. Instead of math I've also tried MathematicaScript and wolframscript -f test.m, they hadn't work either.
Interactively, i.e. running math from the terminal and executing the same Export command, everything works just fine.
I run the script remotely using ssh on a Linux machine.
Is there a way to fix this or any alternative way of saving the data from the script mode?
EDIT.
OK, I resolved the problem and it was pretty dumb. I used Mathematica as an editor and my cells was of the "Input" type, but it should have been of the "Code" type, otherwise, it doesn't work.
Here is the non-working version of the code as it is viewed by Notepad:
(* ::Package:: *)
(* ::Input:: *)
(*Export["/home/my_home_folder/file.txt","hello world"]*)
And here is the working one:
(* ::Package:: *)
(* ::Code:: *)
(*Export["/home/my_home_folder/file.txt","hello world"]*)
math -run "<<test.m"– MannyC Mar 31 '20 at 21:36math– quantum_dog Apr 01 '20 at 08:48math -run "<<test.m;Quit[]"– MannyC Apr 01 '20 at 09:28