It appears that "127" is a Linux Terminal exit flag that indicates that a command could not be found. It is possible that there is a 'PATH' or 'SHELL' variable issue between MATLAB and the Linux shell. Please try the following workarounds:
1. Try the following in order to set the MATLAB path to the Linux environment path. Then, try the "system" command:
>> PATH = getenv('PATH');
>> setenv('PATH', [PATH ':/usr/local/desiredpathtoexe']);
>> [status, cmdout] = system('pwd')
2. If the above does not resolve the issue, then there could be an issue with the 'SHELL' variable. First, we need to determine the system's default shell, as well as the shell currently being used in the Terminal:
a. Find the default startup shell:
b. Find the shell currently used in the Terminal
c. Find the location of that shell's executable. For example, for Bash, the following might output '/bin/bash':
3. Now, find the shell being used by MATLAB:
If this is not the same as the shell used in the Terminal, you can use "setenv" to set it to your desired shell location. Using Bash as an example:
>> setenv('SHELL','/bin/bash')
4. If the issue still persists, make sure that the $SHELL environment variable is set to the value you want before opening MATLAB. Using Bash as an example:
$ export $SHELL=/bin/bash
5. If the issue is still not resolved, and the system default shell and current Terminal shell are different, you can change the system default shell to the desired shell with the following command. Using Bash as an example:
$ chsh -s /bin/bash your_username
This might require logging out and logging in so that the change applies.
6. If you still experience issues, check your .bashrc file or other shell startup files for anything that could be causing issues.
Best Answer