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 Center および File ExchangeLogical についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by