list of csh commands to be run from matlab script

5 ビュー (過去 30 日間)
Aksh Chordia
Aksh Chordia 2020 年 11 月 19 日
コメント済み: Bjorn Gustavsson 2020 年 11 月 23 日
I need to run a list of csh commands on the unix terminal from a matlab script.
Whenever I try to use the system() function, it gets into a infinite loop in the script (the control goes to the terminal in MATLAB.
Until I type the exit command in MATLAB terminal, the control does not go back to the script execution.
As the first line is csh, the rest of the line becomes useless.
I am not able to understand how to achieve this.
The list of commands are as follows:
csh
source /home/install/cshrc
setenv ...
setenv ...
{ some software specifc commands}
Thanks in advance
Aksh
  3 件のコメント
Aksh Chordia
Aksh Chordia 2020 年 11 月 19 日
編集済み: Aksh Chordia 2020 年 11 月 19 日
Is there any alternate way to execute a list of csh commands without using the system function from the matlab script?
Bjorn Gustavsson
Bjorn Gustavsson 2020 年 11 月 19 日
Why not put them into a csh-script?

サインインしてコメントする。

回答 (1 件)

Bjorn Gustavsson
Bjorn Gustavsson 2020 年 11 月 19 日
You might accidentally start a c-shell with your first csh command. My suggestion is that you put all csh-commands into a csh-script, and run that instead of uising matlab to making the list of commands to run. That seems cleaner. If you need to dynamically generate the commands, you should be able to save those to a csh-script (use system to set its permissions to executable) and run that script with system. This seems like a "cleaner" solution than yours, hopefully it works?
HTH
  2 件のコメント
Aksh Chordia
Aksh Chordia 2020 年 11 月 22 日
Thanks for your insight.
But I also want to pass the arguments to the now-interactive command terminal of MATLAB (a software is running on it, which has an interactive command line feature).
I need to run this software through the script (matlab file) by giving it commands in real time which are placed on the script (matlab file ) itself.
Basically, I need to run a software on the MATLAB command prompt and give it commands based on computation and the results it gives. The issue with using "system" function is that, it does not gives back the control to the script until the system function is completely executed (in my case, when the software exits)
Again thank you for the resourceful wiki
Looking forward to hearing back soon.
Thank you
Aksh
Bjorn Gustavsson
Bjorn Gustavsson 2020 年 11 月 23 日
Do I interpret your objective correctly: You want to start a programme/csh-script from matlab use the output of that programme to do some further processing and controll the running of the programme/csh-script from the results of that processing?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by