MATLAB Answers

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

40 views (last 30 days)
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! can I solve it?

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 9 Feb 2021
Open terminal on the Mac. Give the command
/bin/bash -c "$(curl -fsSL"
This is not MATLAB specific: you happen to be asking to execute commands that need the third-party package "brew" installed.
Walter Roberson
Walter Roberson on 4 Aug 2021
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);
error('Failed to locate airspy_rx because "%s"', msg);
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 to remember the setting for each user.

Sign in to comment.

More Answers (0)


Community Treasure Hunt

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

Start Hunting!