I need to locate an installed program in MacOS using Matlab, how can I do that?

조회 수: 1 (최근 30일)
I need to locate an installed program in MacOS using Matlab, how can I do that?
My Matlab code needs to make sure a certain 3rd party program is installed on the computer running the matlab code.
I have a way to do it on Windows ('WHERE /F /R "C:\Users\...'), but how can I do it in Matlab?

채택된 답변

Geoff Hayes
Geoff Hayes 2019년 8월 22일
Mårten - you could try something like
[status, path] = system('find ~/Documents/geoff -name myFile.m')
The above would search in all directories (and subdirectories) for a file named myFile.m. If the file can be found, then the path would be set with the location of that file.
  댓글 수: 2
Walter Roberson
Walter Roberson 2019년 8월 22일
It can pay to first use system() of a 'which' command. which is a shell built in that looks on the Unix path.
In theory you could ask Spotlight about the file, but in my experience it is common for Spotlight to not find what I am looking for.
The unix find command can be slow, especially if you do not confine it to a single mount point (drive) and very slow if you somehow get it searching a Time machine volume.
Sometimes it is best to just try the most common locations like /bin and /usr/bin and /usr/local/bin and look in /opt where Homebrew tends to install, and look in the user's ~/Applications and similar, and look at environment variables for an appropriate name... And if it is not in those places then either prompt the user or force a configuration step be done. Looking through all the drives can take hours (I have more than 10TB these days.)
Mårten Cronander
Mårten Cronander 2019년 8월 28일
Thank you, that helped me.
Best regards
/Mårten

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by