Clear Filters
Clear Filters

How do you run Matlab in batch mode in R2021b Update 2?

13 views (last 30 days)
Hi,
I would like to run a bash script in matlab without GUI.
In version R2020b, it was working, now (R2021b Update 2) it is not.
xy@host:~/dev/$ matlab -batch "compile_lib.sh"
MATLAB is selecting SOFTWARE OPENGL rendering.
< M A T L A B (R) >
Copyright 1984-2021 The MathWorks, Inc.
R2021b Update 2 (9.11.0.1837725) 64-bit (glnxa64)
December 14, 2021
To get started, type doc.
For product information, visit www.mathworks.com.
>> exit
Also tried: matlab -nodisplay -nosplash -nodesktop -r "run('compile_lib.sh');exit;"
But the output is the same as above.
Could you tell me what is the correct method to do this?
  1 Comment
Jan
Jan on 15 Feb 2022
The run() command required the name of a Matlab script. "compile_lib.sh" does not sound like a Matlab script file name.

Sign in to comment.

Answers (1)

Dinesh
Dinesh on 29 Dec 2023
Hi Jean,
To run a bash script, you don't need MATLAB. You can just open terminal and execute the following command:
bash compile_lib.sh
If the script is a MATLAB script (.m file), then you would execute it without opening the GUI using the "run" function. The following is the documentation link:
If you still want to execute bash script using MATLAB only, then you can use the "system" function to do it:
matlab -nodisplay -nosplash -nodesktop -r "system('bash compile_lib.sh');exit;"

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!