Run/Kill a Process Called From Matlab

조회 수: 15 (최근 30일)
Nick Nauman
Nick Nauman 2021년 7월 6일
댓글: Nick Nauman 2021년 7월 6일
I am working on designing a GUI that reads data from a file that is populated from a Perl script. As part of unifying this GUI, I am trying to start and stop the Perl script by using a switch in Matlab App Designer. However, I am not sure how to implement stopping the Perl script.
Details of the Perl Script:
  • The script is designed as an infinite script that collects data every 1 second
  • The script must be manually stopped or killed
I have been researching different methods to implement starting and stopping an external script that is running in the background. For Windows platform, I have found that System.Diagnostics.Process() works for starting the script, getting the PID, and killing the script. Is there any advantages to using these methods instead of the system() Matlab function? If I use the system() function, is there a way to kill the script (I have been unable to find one so far)? For Linux Platform, is there similar methods to those available for the Windows platform for starting and killing the script? I have not been able to find much information online about the Linux Platform.
Any information is greatly appreciated!

채택된 답변

Sam
Sam 2021년 7월 6일
편집: Sam 2021년 7월 6일
You can refer to this post on how to run the external script from matlab. Since the PID will be saved while starting the process, you can then use a methods similar to one used here to kill the script.
This isn't an answer to all your questions, however it does answer some of them.
  댓글 수: 1
Nick Nauman
Nick Nauman 2021년 7월 6일
From my understanding, using System.Diagnostics.Process.Start does not run the script as a background process so Matlab would stop running until the script process ends. This is important because I am plotting the data collected in real-time. Is there a way to get the PID when using the system() Matlab function? I know adding '&' to the the end of the system() input argument command will make it a background process so Matlab will continue to run. Also, I would need to know if you can get the PID using system() when running on Linux platforms because I am unaware of any class like System.Diagnostics.Process() used for Windows platform.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 PID Controller Tuning에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by