Displaying output from .exe file to gui

4 views (last 30 days)
Shaun VanWeelden
Shaun VanWeelden on 7 Mar 2012
Hi,
I am currently writing a gui that assists in the pre and post processing of a large executable. I would like to display a progress log in my gui that updates continuously. I am familiar with evalc and getting output from dos or system commands, but to my knowledge, those are only capable of storing the data after the executable is finished.
My best guess so far is to have the executable write to a file and have that run in the background using the "&" syntax while matlab actively reads the file and then adds new lines to my gui log. Does that seem like a plausible solution?
Thanks,
Shaun

Answers (3)

Sean de Wolski
Sean de Wolski on 7 Mar 2012
Yup, that certainly seems like a plausible solution. Perhaps timer functions will help you read it to MATLAB and update periodically. Good luck on your mission!

Walter Roberson
Walter Roberson on 7 Mar 2012
Consider using mex functions, one of which would use the Windows _popen() function to connect to the executable. Or better yet if you can get it to work for you in Windows, the POSIX popen() function -- that is more portable.
You would need additional mex functions to close the pipe, and to read from the pipe, and (if appropriate) write to the pipe.
Technical note: the pipe operations cannot be done within MATLAB itself; there is no publicly known method to interface between MATLAB's I/O routines and streams created by standard I/O routines.

Dr. Seis
Dr. Seis on 7 Mar 2012
I have a few GUIs that do that exactly. However, I would caution you against "continuously" checking the status of the executed job (i.e., from the start of the job until the job finishes) because you will be wasting a lot of CPU. For example, I have it set up to "pause" for a few minutes between checks. Having the "pause" also allows changes that are made to the GUI (e.g., using "set") to become visible through repainting.
  1 Comment
Dr. Seis
Dr. Seis on 7 Mar 2012
In my case, there can be over several hundred (non-Matlab) jobs/executables running at the same time... each writing various information to their own log file in addition to writing out data to a separate file. My GUI is only looking at the information available in the log file (every few minutes) in order to provide a status/health check for each job. My goal is to basically determine whether a job is queued, running, failed, or completed. If this is similar enough to what you are after then it probably isn't necessary to get into more complicated things - like creating MEX functions.

Sign in to comment.

Categories

Find more on Language Fundamentals 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!