Reputation: 1901
I'm trying to run a script of matlab in BASH in the background the following way:
echo "matlab -nojvm -r p=setpath(/mydirectory/);addpath(p);myscript;exit" |sh &
the error I get is:
sh: line 1: syntax error near unexpected token '('
sh: line 1: 'matlab -nojvm -r p=setpath(/mydirectory/);addpath(p);myscript;exit'
I am running it in a loop so this operation needs to be done several times
Is the error relates to the pipeline? whenever I run the matlab on the bg it is suspended and for simple commands or uploading the gui the pipeline worked well.
is there away to set matlab's path from the BASH?
I try to run the Matlab without the GUI or anything "poping up", when I run with -nodesktop -nojvm it does not open the3 GUI but still enters the matlab and waits in the command line, is there another synthax I can use to make nothing appear on screen?
could use your help, tnx
Upvotes: 4
Views: 2936
Reputation: 1901
found the solution thanks to the next website of the OHIO state Uni
matlab -nodesktop -nodisplay < file.m &> file.out &
it works without any bypassing route
for further explanation go to
http://www.stat.osu.edu/computer-support/programming/background-jobs
Upvotes: 2
Reputation: 360143
Try this:
echo 'matlab -nojvm -r "p=setpath(/mydirectory/);addpath(p);myscript;exit"' |sh &
The outer single quotes protect the inner double quotes so sh
doesn't see the parentheses.
Is there any 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 &
Upvotes: 4