Effacer les filtres
Effacer les filtres

Feedback from Command/DOS window

2 vues (au cours des 30 derniers jours)
Reto Christen
Reto Christen le 9 Mai 2019
Commenté : Reto Christen le 9 Mai 2019
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 commentaires
David Wilson
David Wilson le 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.
Reto Christen
Reto Christen le 9 Mai 2019
Thanks for your reply.
Unfortunately, mycommand.exe not only opens the connection but it keeps it open while using the server. For this reason, mycommand.exe must be running in the background (I should have written this more clearly, sorry). Hence, an ampersand is needed.
Using the dos command actually returned the wanted string, but well, my application cannot continue and everything is 'blocked'.

Connectez-vous pour commenter.

Réponses (1)

Fangjun Jiang
Fangjun Jiang le 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.
  1 commentaire
Reto Christen
Reto Christen le 9 Mai 2019
Thanks for your reply.
This would be the perfect command for me. Unfortunately, I get the error message The syntax of the command is incorrect, but only with the ampersand. system('mycommand.exe >output.txt') works as excpected, but again the same problem with the 'blocked' application.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by