# Wolframscript output not evaluated

Whenever I execute wolframscript code from the command line, my Print[] output doesn't get evaluated, however if I run the exact same file with the Mathematica front end it works fine. I can't work out why this might be happening, it doesn't seem to be a situation where Evalute[] helps.

Example:

M[a_, T_] := (4 \[Pi]^2 a^3)/(G T^2) /. {
G -> Quantity["GravitationalConstant"]
}

(* Assuming inclined around major axis, no change to major axis *)
m1 = M[a, T] /. {
T -> Quantity[15.7, "Years"],
a -> 0.183 * 60^-2 * \[Pi]/180 * Quantity[7.9, "Kiloparsecs"]
} // UnitConvert;
Print["Assuming inclined around major axis: M = " <> ToString[m1, InputForm]]
m1S = UnitConvert[m1, "SolarMass"];
Print["\t = " <> ToString[m1S, InputForm]]


Gives me to following output on the command line, which isn't what I expect:

But when I run it in Mathematica it gives me exactly what I expect

wolframscript --version gives me WolframScript 1.2.0 for MacOSX-x86-64. Mathematica 11.3 is installed.

• I would guess that the front end is using a Wolfram server to interpret the Quantity entities and that the kernel, which is what the script talks to, can't do that. – m_goldberg May 27 '18 at 15:51
• I am having trouble reproducing this, can you share any more details about which version of Mathematica you are using as well as wolframscript --version? I don't think a front end is needed in this case. – chuy May 29 '18 at 15:00
• @chuy Sure: WolframScript 1.2.0 for MacOSX-x86-64. The Mathematica front end is reports version 11.3 – Jasper May 30 '18 at 15:44
• What do you see when you try wolframscript -code 'Quantity[10,"pounds"]'? – chuy May 30 '18 at 17:00
• @chuy I get Interpreting unit .... Quantity[10, Pounds] – Jasper May 31 '18 at 1:47

So when I copied the file into the question above, I copied from the Mathematica front-end, which interprets the file contents slightly differently. The contents of the file is actually

#!/usr/bin/env wolframscript

M[a_, T_] := (4 π^2 a^3)/(G T^2) /. {
G -> Quantity["GravitationalConstant"]
}

(* Assuming inclined around major axis, no change to major axis *)
m1 = M[a, T] /. {
T -> Quantity[15.7, "Years"],
a -> 0.183 * 60^-2 * π/180 * Quantity[7.9, "Kiloparsecs"]
} // UnitConvert;
Print["Assuming inclined around major axis: M = " <> ToString[m1, InputForm]]
m1S = UnitConvert[m1, "SolarMass"];
Print["\t = " <> ToString[m1S, InputForm]]


I had input π as a unicode symbol. Wolframscript didn't interpret this as the constant Pi, but when I open the file with the front-end it automatically converts any instance of π to \[Pi]. The command line input was therefore unable to evaluate the expression as it doesn't know what the symbol π is, and there also seems to be some encoding issues in the output.

Strangely the unicode input seems to work if I invoke the file with wolframscript -script, but not just with wolframscript or with wolframscript -file. (This seems to be discussed here.)

Sorry to waste anyone's time with an incorrect question.

Mea culpa!