I'm not sure on which operating system you are and whether this makes a difference, but your 4 choice don't do the same.
math -run file.m
When you change this command to
math -run < file.m then it does the same as the next (wrong) alternative.
Doesn't do anything with the content of
file.m at all, because the
-run option expects a command like
math -run Print. Additionally, the command is not ran in batch mode like you would expect it from a script. Instead, an interactive command-line Mathematica session is opened. This is the same (although the session is quit instantly) for
math < file.m
where the content of
file.m is executed, but
file.m is not considered to be a script. You can easily see this when you create a script file with she-bang like
the the output of
math < file.m looks pretty awesome:
Mathematica 10.0 for Linux x86 (64-bit)
Copyright 1988-2014 Wolfram Research, Inc.
Out= -script + -------------------------------
bin local MathematicaScript usr
In:= In:= Hello
Your last alternative seems to miss the
-script option which is (as stupid as this may sound) required, even for the
MathematicaScript command. Therefore, I need to run
WolframScript -script file.m
or I get an error
error: Need to provide the -script option. Usage: -script
which is pretty lame.
If I had to give a suggestion, I would tell you to always include the she-bang in your file and make the file executable with
chmod +x. Then you can simply call