Use command line in matlab using ! and zsh:1: command not found: is displayed

65 次查看(过去 30 天)
Hi
I'm using MATLAB 2020b and Big sur OSX
before catalina version, in my memory...
I was using well with ! for call mac command line
but now in big sur when I use ! and matlab display zsh:1: command not found: brew or other package!
so...how can I solve it?
  3 个评论
Walter Roberson
Walter Roberson 2021-2-9
zsh is the Z shell, which is one of the successors to ksh (Korne Shell). Apple made it the default.

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2021-2-9
Open terminal on the Mac. Give the command
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
This is not MATLAB specific: you happen to be asking to execute commands that need the third-party package "brew" installed.
  8 个评论
Michael
Michael 2021-8-3
@Walter Roberson I just answered in the other related issue before seeing your answer here. It seems that I stumbled across your first easiest method. I had noticed your second method in the documentation file for system.m. I did not know that each shell session could have their own PATH. Part of the issue I am dealing with is that I am trying to incorporate this into a standalone application I built in App Designer. In that case, having the users manually look up the location of airspy_rx is not preferable.
If I use your second method with the export call within system.m, will that permanantly add the path for future system calls or only update the PATH for that particulare system call?
Thanks.
Walter Roberson
Walter Roberson 2021-8-4
编辑:Walter Roberson 2021-8-4
The shell export command only affects the environment for that shell and the subprocesses of the shell, and each system() call is a different process.
At the MATLAB level you can do things like
setenv('PATH', getenv('PATH')+":/usr/local/bin")
and that should affect anything started using system() or the ! operator. But that does not tell you where your executable is.
To locate the executable, you can try:
[status, msg] = system('exec -a -ksh /bin/ksh -c "which airspy_rx"');
if status == 0
airpath = string(regexprep(msg, '\r?\n', ''));
setenv('PATH', getenv('PATH')+":"+airpath);
else
error('Failed to locate airspy_rx because "%s"', msg);
end
This should work if the user has ksh or zsh configured as their login shell, and someone has configured the appropriate configuration files so that airspy_rx is normally on their path when they log in.
If they happen to have configured bash instead, then
bash -l -c "which airspy_rx"
would be appropriate.. you could try that within the "else".
But at some point you are going to encounter a user whose shell configuration does not have the executable on the path, and you going to have to uigetfile() or something similar.
You might want to use the MATLAB preferences system https://www.mathworks.com/help/matlab/ref/setpref.html to remember the setting for each user.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by