3

I have read this thread on how to correctly add the paths:

How to correctly add a path to PATH?

I have already exported path

/usr/local/proc_mt/bin:usr/local/MATLAB/MATLAB_Production_Server/R2015a/bin

Still I do not know how should I change my matlab shell script, in a way that would enable me to use the matlab.

1
  • 2
    Did you notice that you're missing a slash / at the beginning of usr/local/MATLAB... ? – RobertL Nov 24 '15 at 5:35
0

In the shell script, simply include the following:

PATH="$PATH:/usr/local/proc_mt/bin:usr/local/MATLAB/MATLAB_Production_Server/R2015a/bin"

If there are executables with the same name as other executables in your $PATH, and you wish to give the Matlab executables preference over the others, put it before your current environment $PATH like so:

PATH="/usr/local/proc_mt/bin:usr/local/MATLAB/MATLAB_Production_Server/R2015a/bin:$PATH"

In some scenarios you may need to export this environment variable by doing

export PATH=[the solutions I listed above]

...which can never hurt (and in some cases may make obscure issues easier to troubleshoot)

The issue you are probably experiencing is that you are setting the $PATH in your shell, and the actual script is defaulting to the default environment $PATH. You can avoid this, as said before, by explicitly setting the $PATH from within the script itself.

6
  • Are you thinking of matlab shell script?Should I change the ownership? -r-xr-xr-x 1 root root 58454 Dez 29 2014 matlab – MikiBelavista Nov 23 '15 at 16:22
  • Only if you are running it as root. Otherwise, chown to the user who will be running the script. If the name of your script is simply matlab and there is also an executable in your $PATH called matlab, then that is your problem. Change the name of the script to somethingelse.sh – rubynorails Nov 23 '15 at 19:19
  • but how did you find the location of the binaries files or MATLAB in the first place? – Charlie Parker Feb 1 '16 at 18:10
  • What is proc_mt suppose to be? this doesn't work for me, how did u find out what directory paths to put in there? – Charlie Parker Feb 1 '16 at 19:29
  • @CharlieParker - that's just part of this specific user's $PATH, which is a directory (probably unrelated to MATLAB) that includes executable files which can be referenced directly by name rather than their full path. My answer was not MATLAB-specific; it answered the question of how to correctly set a $PATH environment variable for a shell script. One must find one's own $PATH by executing echo $PATH. If you want a script that uses MATLAB executables, find where they exist, and include export PATH="/path/to/MATLAB/bin/directory:${PATH}" in your shell script. – rubynorails Feb 2 '16 at 5:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.