Stop system() command if it takes too long

12 visualizaciones (últimos 30 días)
Paul Medl
Paul Medl el 23 de Ag. de 2019
Respondida: sourabh kondapaka el 17 de Mzo. de 2020
Under Windows: Close .exe opened by system() if it takes too long to end/execute/self close.
Best with time period, that is only exhausted if .exe needs that long. Program should proceed if .exe closes before end of time period.
Didn't work:
t=timer;
t.TimerFcn=system('C:\Esotec\DFDC_070es33_win32\bin\dfdc.exe < DFDC_script.txt');
t.StopFcn=system('kill ');
t.Period =2;
t.TasksToExecute=1;
t.ExecutionMode='fixedRate';
start(t);

Respuestas (1)

sourabh kondapaka
sourabh kondapaka el 17 de Mzo. de 2020
TimerFcn, startFcn and StopFcn arguments of the timer class expect Character vector, string scalar, function handle, or cell array defining the timer callback function. You must define this property before you can start the timer.
As you are trying to execute the “system” command.
t = timer;
t.TimerFcn = @(~,~)system('C:\Esotec\DFDC_070es33_win32\bin\dfdc.exe < DFDC_script.txt');
t.StopFcn = @(~,~)system('kill ');
t.Period =2;
t.TasksToExecute=1;
t.ExecutionMode='fixedRate';
start(t);
For further reference on timer object: Timer Object
For more information on how to call custom callback function’s : Timer Callback Functions

Categorías

Más información sobre Code Execution en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by