Get the status using system(command &) when program has been closed
31 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Mario Malic
el 24 de Ag. de 2020
Comentada: Walter Roberson
el 23 de Jun. de 2022
Hello guys,
I have another question to ask for today.
I am running an .exe file that takes some time to finish and to output the status. This command runs within app designer and it makes the application unusable (I can click on the stuff but nothing will refresh during system command).
Question: How can I make the App drawnow during the ([ExeFile ' &']) or system (ExeFile)?
Since ExeFile generates another file, I wanted to check if it exists as follows:
system ([ExeFile ' &']); %
while isfile(File_Check) == false
drawnow
pause (0.5)
end
But it turns out that file is generated immediately and it increases size as the ExeFile is running, so this does not seem like a good approach.
I also checked the fileattribute for the File_Check and they do not change during the execution. Edit: As stated here https://www.mathworks.com/matlabcentral/answers/296657-how-can-i-check-if-i-have-read-or-write-access-to-a-directory it turns out not to be reliable.
Are there any other ways you can think of doing this?
Edit: During the ExeFile run, I get permission denied when I want to delete the file, so, I can just try renaming the file and then rename it back when the command succeeds. But I don't see this as a great idea.
4 comentarios
Respuesta aceptada
Mario Malic
el 26 de Ag. de 2020
Editada: Mario Malic
el 26 de Ag. de 2020
4 comentarios
Jonathan Gimeno
el 23 de Jun. de 2022
Editada: Jonathan Gimeno
el 23 de Jun. de 2022
Thanks for the proposed solution, unfortunately I dont have available parfeval function.
I choose to do it the hard way:
% Execute in background the system command:
command = "<command_name> & "
system(command)
% get system command pid
[status, command_pid ]= system("ps aux |grep [c]ommand_name | awk '{print $2}'");
check_pid_is_alive = strcat("ps --pid ", command_pid);
while ~(system(check_pid_is_alive))
% do something
end
Más respuestas (0)
Ver también
Categorías
Más información sobre Startup and Shutdown en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!