Testing Bash variable to decide whether to use MATLAB or Runtime
Afficher commentaires plus anciens
I am using a Bash script to test a Java package created from an m-file function using Compiler SDK. I want the script to use either Matlab, if it is installed, or the Matlab Runtime if the former is not installed.
Based on the Stack Overflow answer https://stackoverflow.com/a/17157187, I tried testing the flow control at the Bash command line:
$ UseMLorRT=MATLAB # Next, test if this choice is properly recognized
$ if [ "$UseMLorRT"="MATLAB" ]; then echo UseMatlab; else echo UseRuntime; fi
UseMatlab
$ if [ "$UseMLorRT"="Runtime" ]; then echo UseMatlab; else echo UseRuntime; fi
UseMatlab
The setting `UseMLorRT=MATLAB` is not being recognized. In the second `if-else` statement above, `echo UseRuntime` should be executed, but it is not. I get the same behaviour by comparing using "==" instead of "=" and if I use double square brackets instead of single square brackets.
Can anyone see what I am doing wrong?
2 commentaires
Walter Roberson
le 27 Avr 2023
https://linuxize.com/post/bash-case-statement/ you could use a case statement
FM
le 27 Avr 2023
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Troubleshooting in MATLAB Compiler SDK dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!