Reputation: 1848
System commands can be run on Matlab using the system()
syntax. In a unix environment, what shell does matlab choose for executing system commands? The first entry of /etc/shells
? Can the default behavior be changed? I am looking for a general solution that will apply to all system calls rather than one that involves forking a child process with the shell of interest as in system('/bin/ksh <command>')
.
Upvotes: 0
Views: 902
Reputation: 181
As this document says,
On UNIX, MATLAB uses a shell program to execute the given command. It determines which shell program to use by checking environment variables on your system. MATLAB first checks the MATLAB_SHELL variable, and if either empty or not defined, then checks SHELL. If SHELL is also empty or not defined, MATLAB uses /bin/sh.
MATLAB's system command uses MATLAB_SHELL or SHELL, or /bin/sh. You can change the default shell by setting environment variable MATLAB_SHELL or SHELL.
For example, if you choose MATLAB_SHELL, before launching MATLAB, you need to set
setenv MATLAB_SHELL /bin/ksh
in csh, tcsh.Or,
export MATLAB_SHELL="/bin/ksh"
in bash.
Then, MATLAB will use /bin/ksh with system command.
If you use /bin/ksh every time, it's better to set MATLAB_SHELL in your ~/.bashrc and so on.
Upvotes: 1