The first line in a Mathematica executable script specifies the directory of WolframScript, e.g.

#!/usr/local/bin/WolframScript -script

Assume I want to run a Mathematica executable script on two different computers, with different directories of WolframScript. This means running the script on the first computer requires the first line to be e.g.

#!/usr/local/bin/WolframScript -script

while on the other computer the first line needs to be (say)

#!/usr/opt/mathematica/bin/WolframScript -script

How can I write the Mathematica exectubale script so that it runs on both computers without changing the first line?


1 Answer 1


I'm not on Unix but Windows but you should be able to do this. Booting up mac to test.

#!/usr/bin/env WolframScript

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.