MATLAB and several command prompt commands
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello,
I have a device which I want to transfer files from through tftp. To do this I'm opening a command prompt and writing
tftp -i 10.0.0.22 get dmafiles-0
This begins the transfer. In total I need to transfer files 0-7.
I'm trying to make MATLAB run these commands for me without locking itself into busy mode.
I can do this if I create a function file with this command and use batch(function) to run this script:
ch = 0:7;
for i=1:length(ch)
command = sprintf('tftp -i 192.168.178.100 get dmafiles-%d', ch(i));
system(command)
end
This will offload the transfer to a different worker and not lock the main MATLAB window. However, this will transfer the files in a serial manner, one after the other. If I open several command prompts, I can transfer several files in parallel.
The issue is that I don't know how to offload each transfer onto a different MATLAB worker, which will then run the transfer of its respective file in a different cmd window.
Should I create 8 functions, each corresponding to its own file, and then batch all of them?
i.e. CH1, CH2, ..., CH8 and then batch(CH1), batch(CH2),..., batch(CH8)
Is there a better way?
In short, the issue is - open several command prompts and run a command in each. Works when done manualy, looking into how to implement in MATLAB.
1 comentario
Respuestas (2)
Walter Roberson
el 12 de En. de 2023
For Windows use System.Diagnostics.Process to create the transfer processes. You can invoke tftp directly without creating a command window, and you have control over the output stream.
Ver también
Categorías
Más información sobre Component-Based Modeling 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!