Feedback from Command/DOS window
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
I have some problems while working with an external command window.
In Matlab I have to run an executable which will connect to a server. Setting up this connection takes roughly 10 to 20 seconds and the port number of the connection is then written into this command window. I am now looking for a possibility to read out this port number, since it is vital for my next steps in Matlab.
I tried to run the command
[status,cmdout] = system('mycommand.exe &');
However, since the server first has to connect, cmdout is just an empty string. I there a possibility to 'rerun' the command to get the correct cmdout-value?
Right now I am using a Matlab Input-Dialog to get the port number manually. It works but a nicer automated solution would be prefered.
I would greatly appreciate your help.
2 Kommentare
David Wilson
am 9 Mai 2019
You could try the dos command, without the trailing ampersand. That way Matlab might wait, and not try to do it in the background.
Antworten (1)
Fangjun Jiang
am 9 Mai 2019
I don't know if this old trick could work. Try system('mycommand.exe & >output.txt'). Hope all the output would be re-directed to the specified text file. It might take a while for your mycommand.exe to finish. But once the output is saved in a text file, your next run could read it and get the info.
Siehe auch
Kategorien
Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!