I'm running the Mathematica kernel
math from inside a makefile to generate C++ code, like so:
a.out: g++ -o a.out main.cpp main.cpp: math -run "<< \"generate_main.m\"" # generates main.cpp
However, sometimes there is no Mathematica license available on the machine where
make is called (license has expired, connection to license server has been lost, ...). In such a case, the Mathematica kernel does not quit, but instead waits for the user to input a license password. So,
make will never finish. In such a case, I'd like
math to quit with a non-zero exit code. How can this be achieved?
Most convenient would be a command line option for the Mathematica kernel, like
math -quit-if-no-license could then for example also be used in a
configure script to check if the Mathematica kernel can be run.