Filter löschen
Filter löschen

system() call on windows, R2012b & R2014b, handling error popups

5 Ansichten (letzte 30 Tage)
Stefan
Stefan am 22 Dez. 2014
Beantwortet: Stefan am 4 Feb. 2015
Hi
I try to run an external program via system() call. In a normal command shell and execute from R2012b everything works as expected, in R2013b nothing happens and my status after the system call is "-1.0737e+09" (return is empty). Same behavior if I open a cmd prompt in matlab R2013b (system('cmd')) and try to start it there.
It seems like some dependency/library of the external software is not found, because if I rename the folder of one of the needed dependencies, I get the exact same behavior in R2012b. If I than run the command directly in a cmd-prompt, a msg-box error with the unavailable dependency pops up, which matlab probably cannot return?
I tried to compare every environment variable between R2012b and R2013b (by the way R2014b does not work, either) but java.lang.System.getenv() returns exactly the same values for both Matlab versions, except __COMPAT_LAYER (ElevateCreateProcess vs. DisableUserCallbackException), but setting the environment variable in R2013b to the same value as in 2012 does not solve the problem for me.
Is there any other difference between the system call in R2012 compared to R2013? Or compared to a "normal" cmd prompt?
win7 64bit, same system (i.e. hardware) for both versions
any ideas?
  2 Kommentare
Stefan
Stefan am 22 Jan. 2015
Ok so I'm a step closer to the solution, the problem in my case is libstdc++-6.dll located in matlabroot/bin/win64 (and also in the folder of the external library). When I run the cmd from matlab, the path changes to matlabroot/bin/win64;path, therefore the dll in matlabroot/bin/win64 is used instead of using the one of my library. I try to fix this problem for my particular application, unfortunately renaming the dll before running the external program and reverting the change afterwards is not possible due to access rights. My idea is to remove the matlab dir from the path before running my command. Something like that should do the trick: system(['set path=%path:' matlabroot '\bin\win64;=% & myCall']); Unfortunately this does not work, not sure why. If I try it manually from matlab, it works:
system('cmd') set path=%path:' matlabroot '\bin\win64;=% myCall
But I need to bring these two commands sequentially into one system call. Any ideas? Or is there another way to change the PATH used by system()?
PRATIK JAISWAL
PRATIK JAISWAL am 26 Jan. 2015
I have a similar problem . I have a written code for 2012b and it works properly with old version. But for 2014b version the MATLAB crashes and says error with the file. 2012 was a better version. The 2014 is having issues big time. Can someone please help me solve this

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Philip Borghesani
Philip Borghesani am 26 Jan. 2015
The chained commands work for me as seen buy the output of:
system(['path &set path=%path:' matlabroot '\bin\win64;=% & path']);
There may be some other problem with how your program is running.
Other possible ways to modify the path before running your program:
  1. use setenv from MATLAB. The system command will pick up the path from the MATLAB environment but this should not effect the executing MATLAB. You may need to do this before the first call to system because in some versions of MATLAB a system shell is held and reused.
  2. Create a batch file to modify the path and call your program then run that with the system command. you can even create a new command shell with cmd /k to launch the batch file allowing more isolation.

Stefan
Stefan am 4 Feb. 2015
Ok for me the command is not working, at least the first entry of the path (in my case %matlabroot%\bin\win64 is not removed from the path. Nevertheless by creating a batchfile removing the first entry from the path first and then execute my call works fine! By the way, getenv('path') returns the path without matlabroot\bin\win64, therefore there's no point in removing the directory from the environment variable, at least in my configuration. Also my matlab does not seem to reuse a system shell, the %matlabroot%\bin\win64 gets added to the path each time I run system(). Thanks for the help!

Kategorien

Mehr zu Software Development Tools finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by