Matlab immediately returns exit code

I create various matlab.m files using python and then run them using a subprocess. When the files are finished, I would like to delete them:

    command = ['C:\\MatlabR2012b\\bin\\matlab.exe', '-nodesktop', '-nosplash', '-r', 'mfile']
    matlab = subprocess.Popen(command) # launch matlab with m file
    matlab.wait() # wait for matlab to finish before deleting .m file
    print "delete"
    os.remove(self.filename)

The problem is that matlab.wait () never waits, since matlab immediately returns a return code of 0. Is there any other way to check if Matlab is complete?

+4
source share
1 answer

Windows has both bin\matlab.exe, and bin\win32\matlab.exe(or bin\win64\matlab.exe). The first is just a wrapper around the last and pretty much comes out right away.

bin\win32\matlab.exe , -wait bin\matlab.exe.

+4

Source: https://habr.com/ru/post/1536929/


All Articles