Unix commands in Matlab

조회 수: 5 (최근 30일)
Jim O'Doherty
Jim O'Doherty 2015년 4월 2일
댓글: Derek 2016년 10월 14일
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

답변 (1개)

Jim O'Doherty
Jim O'Doherty 2015년 4월 2일
편집: Jim O'Doherty 2015년 4월 2일
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
Derek
Derek 2016년 10월 14일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by