Feedback from Command/DOS window
2 views (last 30 days)
Show older comments
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 Comments
David Wilson
on 9 May 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.
Answers (1)
Fangjun Jiang
on 9 May 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.
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!