Why do I receive an error message when using the command UNIX in MATLAB 6.0 (R12) on UNIX platforms?

12 views (last 30 days)
When I tried to use the following command on MATLAB 6.0 on a SUN machine I receive the following error message:
unix('who')
ERROR: if: Expression Syntax.
In addition, during another session on a SGI machine, I tried the following and received a different error:
[s,w] = unix('who')
ERROR: tcsh: using dumb terminal settings.
!vi
ERROR: Unknown terminal type 'MATLAB Command Window'!

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 24 Apr 2023
Edited: MathWorks Support Team on 24 Apr 2023
The "if: Expression Syntax" error can occur if you have the SHELL environment variable set to something different than what is expected. For example, one MATLAB user reported this error and was able to trace it to their use of "tcsh" instead of "csh." Once they explicitly set the SHELL variable in .matlab6rc.sh to "csh" the "if: Expression Syntax" was resolved.
The "tcsh: using dumb terminal settings" was corrected when the user changed a different environment variable in .tcshrc using the following command:
setenv LANG C
Note: The method for setting environment variables depends on which shell you are using.
If you are using "csh" or "tcsh", the "if: Expression Syntax" error may also occur as a result of a syntax error in either the .cshrc or .tcshrc files. Please examine the appropriate file for any errors. Alternatively, you can have MATLAB use "sh" by entering the following before starting MATLAB:
setenv MATLAB_SHELL=/bin/sh
If you are getting the error about unknown terminal type, this is happening because Terminal Emulation is not supported in MATLAB. Instead of using the following command
!vi file.m
you should try using this command:
xterm -e vi &
Some additional information on the related UNIX/Linux command bang (!) and why it might not work in the UNIX/Linux version of MATLAB can be found below:

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!