irritable_phd_syndrome
irritable_phd_syndrome

Reputation: 5077

Testing if Matlab license is in use from the command line / bash

I'm running CentOS 6.9. I want to test if a Matlab license is currently in use from the command line. Currently, the best way I can think of is

/opt/matlab/R2018b/bin/matlab -nodesktop -nosplash -r "exit;"
export RETURN_VALUE=$?

Is there a better way of doing this? Perhaps catching the actual licensing error from Matlab itself? I don't want to go the grep approach in this instance.

I'm looking for something where I could use the Matlab executable (or some other Mathwork's executable) to just test if the license is available.

EDIT : Matlab emits different licensing errors depending on if the the license is unavailable vs. if you are an unauthorized user. It is important to be able to distinguish between the two because I'd ultimately like to write a prolog script for Slurm to handle the differences between the two. Some users are permitted to use the license, others are not. This is why my above example is inadequate.

Upvotes: 2

Views: 735

Answers (1)

Suever
Suever

Reputation: 65460

You should be able to utilize the lmutil command-line utility that is distributed with MATLAB, specifically with the lmstat command. The location of this command-line program depends on your system, but it's typically in $MATLAB_ROOT/etc/$arch

Specifically to get the status of licenses, you can use the lmstat option:

./lmutil lmstat -a -c /path/to/license

This will parse the license file and communicate with the license server specified in the file to get the status of its licenses.

If you check out the documentation for lmutil (./lmutil --help) and lmstat (./lmutil lmstat --help) you'll see a number of different options that may be useful for what you are trying to accomplish.

Upvotes: 5

Related Questions