Clear Filters
Clear Filters

Help with command system

1 view (last 30 days)
Anna Levy
Anna Levy on 17 Dec 2021
Edited: Walter Roberson on 20 Dec 2021
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 !!

Accepted Answer

Walter Roberson
Walter Roberson on 17 Dec 2021
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 Comments
Walter Roberson
Walter Roberson on 19 Dec 2021
Edited: Walter Roberson on 20 Dec 2021
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 on 20 Dec 2021
Thanks a lot !!! it works fine now

Sign in to comment.

More Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!