MATLAB: A peculiar problem when using system command to run a c shell script from matlab.

gfortransystem command

I need to run a shell script from matlab by using system command (or unix, or !), but none of the FORTRAN executable files that I need actually works with "system", even though it still gives me status flag as 0, which usually means the code works well but it is obviously not the case for today. Has anyone ran into similar problems before? The shell script works perfectly fine otherwise. I never ran into such a strange problem with "system" command before, and I have not found anything vaguely related to this from the Internet. πŸ™

Best Answer

I am going to speculate a bit here:
Possibly gfortran links against a different libc than g77 does, and the only g77 uses is the one provided with MATLAB.
If this speculation is correct then you should be able to determine it by downloading and applying "Dependency Walker".
The libc provided with MATLAB would know how to communicate with MATLAB's stderr and stdout.
If my speculation is correct then using g77 would be easiest. You might be able to convince gfortran to link against an alternate libc but my recollection is that gfortran needs some of the facilities in Microsoft's libc.