Unix commands in Matlab

6 visualizaciones (últimos 30 días)
Jim O'Doherty
Jim O'Doherty el 2 de Abr. de 2015
Comentada: Derek el 14 de Oct. de 2016
Hi,
I've installed a series of binaries which appear in usr/local/bin on my MACOSX (They're called DCMTK). The usr/local/bin folder appears on the path as expected:
/Users/jim/Library/Enthought/Canopy_64bit/User/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin:niftyreg_install/bin
I can run these commands as expected from any folder in a Terminal window, however I can't seem to run any of them from within Matlab (2014b) using the command:
cmd=['dcmdump -h'];
system(cmd)
/bin/bash: dcmdump: command not found
Running 'env' in a Terminal shows that I am using the same SHELL as Matlab:
SHELL=/bin/bash
My question is why is it when Matlab invokes bin/bash it is not finding the binaries in usr/local/bin? Is there something I need to update?
Thanks,
Jim

Respuestas (1)

Jim O'Doherty
Jim O'Doherty el 2 de Abr. de 2015
Editada: Jim O'Doherty el 2 de Abr. de 2015
I've managed to get some help elsewhere on this issue, thought I'd post here in case anyone else has the same problem.
Echo the PATH from MATLAB itself:
cmd=['echo $PATH']; system(cmd);
In my case this gave:
/usr/bin:/bin:/usr/sbin:/sbin
and does not include the usr/local/bin where my binaries are stored. Therefor this needs to be added via
setenv('PATH', [getenv('PATH'),':','/usr/local/bin']);
which now gives:
cmd=['echo $PATH']; system(cmd);
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
If you start Matlab from a terminal the PATH is different, and contains usr/local/bin, but starting it the "usual" way through Applications causes a different PATH. No idea why!
Jim
  1 comentario
Derek
Derek el 14 de Oct. de 2016
Thanks Jim. I've run into exactly the same problem. It would be great if Matlab run from the icon would grab all of the environmental variables.

Iniciar sesión para comentar.

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by