Why does my bash script work in the terminal but not when executed in Matlab?

8 views (last 30 days)
Hi,
I have a script that I use in Matlab, which uses a call to the shell to execute a script in order to run a program (in this case, LS-Dyna). The script works fine if I run it in the terminal, but I get an error if I use Matlab to run it.
The script is very simple:
#!/bin/bash
lsr800 i=Header_main.k r=d3dump01
where lsr800 is an alias to the ls-dyna executable, and the matlab command I use to run it is:
! bash lsDynaRunScript.sh
When run from Matlab, the ls-dyna simulation process starts successfully but fails when processing the first calculation. The output is:
initialization completed
1798 t 1.0000E+02 dt 4.00E-02 write d3plot file 10/12/16 13:25:09
BEGIN implicit statics step 257 t= 1.0035E+02 10/12/16 13:25:09
min. memory for in-core stiffness factorization= 37.1 Mw
*** Error in `/usr/local/lstc/ls-dyna_smp_d_r8_0_0_x64_redhat59_ifort131_sse2': free(): corrupted unsorted chunks: 0x0000000018885140 ***
*** Error in `./lsDynaRunScript.sh: line 5: 24218 Aborted (core dumped) /usr/local/lstc/ls-dyna_smp_d_r8_0_0_x64_redhat59_ifort131_sse2 i=Header_main_kg_m_sec.k r=d3dump01
I've previously had this working without any problems, but I've just updated from R2014b to R2016b, and it no longer works. As it runs fine when running in the terminal directly I assume it is a problem with the way Matlab invokes the shell. Is there some sort of memory limit or something at play here, or an environment variable that I set the first time around and have forgotten about?
If anyone has any suggestions I'd be very grateful. I'm running on Ubuntu 14.04 in case it helps.

Answers (1)

Jeremy Hughes
Jeremy Hughes on 12 Oct 2016
I'd check the environment variables in MATLAB versus your console. MATLAB makes changes and might have altered something you script is looking for.

Categories

Find more on Get Started with MATLAB 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!