I need some help here on this point : I want to run multiple jobs at the same time from matlab on my mac. This works fine using this command system('"./Astra"charge &').
The problem is that using '&' I can indeed run multpile jobs but, they are launched as background tasks and I cannot see their evolution. I would like that for each job a terminal is laucnhed in which the job run. If I don't use '&' I can observe the job evolution but, since it run in the matlab window, it is one per one and I cannot tun multiple jobs at the same time.
Could someone solve this isuse ?
Thanks !!

 採用された回答

Walter Roberson
Walter Roberson 2021 年 12 月 17 日

0 投票

At least for now, you can use applescript
!osascript -e 'tell app "Terminal" to do script "./Astra charge"'
Except it looks like your starting directory is likely to be your home directory, so you probably need to specify a full path.
I see a claim that you can put two commands separated by semi-colon -- but I also see it claimed that two is the limit.
The reply from the above would look something like
tab 1 of window id 6550
which is information that can be used to control the application.

5 件のコメント

Anna Levy
Anna Levy 2021 年 12 月 18 日
thanks !! it looks like it works but I don't know how to add the path of the file ?
Walter Roberson
Walter Roberson 2021 年 12 月 18 日
sprintf() or compose() the command line and system() that.
sprintf('... do script "./Astra %s"', escaped_name)
where escaped_name is probably something like "'"+filename+"'"
Escaping the name would be needed because the path for the file to pass to Astra might include spaces or special characters and you need to ensure that the path becomes a single token for zsh purposes
Anna Levy
Anna Levy 2021 年 12 月 18 日
I see but this :
!osascript -e sprintf('tell app "Terminal" to do script "Astra %s"',name)
is not working !
what is wrong ?
Walter Roberson
Walter Roberson 2021 年 12 月 19 日
編集済み: Walter Roberson 2021 年 12 月 20 日
The ! command can only ever have a constant string after it.
The ! command is short-hand for using system() but system() is more general.
cmd = sprintf('osascript -e ''tell app "Terminal" to do script "Astra ''%s''"', name);
[status, output] = system(cmd)
Anna Levy
Anna Levy 2021 年 12 月 20 日
Thanks a lot !!! it works fine now

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeThird-Party Cluster Configuration についてさらに検索

製品

リリース

R2018a

質問済み:

2021 年 12 月 17 日

編集済み:

2021 年 12 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by