Running Matlab on a BASH Background

I am trying to run a script from matlab in BASH in the background as follows:

echo "matlab -nojvm -rp=setpath(/mydirectory/);addpath(p);myscript;exit" |sh & 

I get an error:

 sh: line 1: syntax error near unexpected token '(' sh: line 1: 'matlab -nojvm -rp=setpath(/mydirectory/);addpath(p);myscript;exit' 

I run it in a loop, so this operation needs to be done several times

  • Is the error related to the pipeline? whenever I run matlab on bg, it pauses, and for simple commands or loading gui, the pipeline works well.

  • Is there a place to set the matlab path from BASH?

  • I try to start Matlab without a GUI or anything “pop-up”, when I start with -nodesktop -nojvm, it does not open the 3rd GUI, but still enters matlab and waits on the command line if there is another syntax that can i use so that nothing is displayed on the screen?

can use your help, tnx

+4
source share
2 answers

found a solution thanks to the following OHIO Uni state website

 matlab -nodesktop -nodisplay < file.m &> file.out & 

it works without going around the route

for further explanation go to

http://www.stat.osu.edu/computer-support/programming/background-jobs

+2
source

Try the following:

 echo 'matlab -nojvm -r "p=setpath(/mydirectory/);addpath(p);myscript;exit"' |sh & 

External single quotes protect internal double quotes, so sh does not see parentheses.

Is there a reason you can't just:

 matlab -nojvm -r "p=setpath(/mydirectory/);addpath(p);myscript;exit" & 

or perhaps:

 matlab -nojvm -r "p=setpath(/mydirectory/);addpath(p);myscript;exit" </dev/null & 
+4
source

Source: https://habr.com/ru/post/1414802/


All Articles