Issues executing bash commands from matlab (windows 10)
2 views (last 30 days)
Show older comments
Hello all,
I have a question very similar to this one, regarding executing bash commands from the matlab command-line.
For context, I'm using MATLAB R2019a (9.6.0.1150989 Update 4) on Microsoft Windows 10 Pro Version 10.0.19041 Build 19041
The command I'm trying to execute is
! bash -c c:/nrn/bin/mknrndll
This gives me the output
0 [main] sh 20084 sync_with_child: child 20888(0x244) died before initialization with status code 0xC0000142
848356 [main] sh 20084 sync_with_child: *** child state waiting for longjmp
c:/nrn/bin/mknrndll: fork: Resource temporarily unavailable
When I start bash from the windows start menu (by typing in bash and pressing enter), I can cd to the folder in question and execute
bash-4.4$ c:/nrn/bin/mknrndll
which produces the expected output (a compiled .dll file from a bunch of .mod files, and some other extrania).
I can execute
! bash -c ls
from inside MATLAB without problems and recieve the expected output.
On closer inspection, this probably isn't strictly speaking a MATLAB issue because I get the same error if I first open cmd.exe, then start bash, then cd, then try mknrndll I get the same error from as within Matlab. Nevertheless, does anyone have any ideas what's going on here (and are there any other ways of executing a sh script on windows via Matlab?)
1 Comment
Rik
on 11 Jun 2021
The general idea with the command line from Matlab is that you should make sure your script runs as expected without any user interaction.
So you need to find a way to queue commands. It looks to me like you can simply queue the cd and your call with the normal bash syntax.
Answers (0)
See Also
Categories
Find more on Introduction to Installation and Licensing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!