Running a bash script from MATLAB

22 ビュー (過去 30 日間)
Fabio Ambrosio
Fabio Ambrosio 2021 年 7 月 1 日
回答済み: Walter Roberson 2021 年 7 月 2 日
Hi,
I have a .sh script that needs to be run from MATLAB to open another program.
The command (/s/test2.sh) typed directly into the UNIX terminal works successfully.
The problem is: when running the same command in MATLAB, using the "system" and "unix" function, MATLAB returns the status '0' but the .sh script does not open the other program. I know the script was running because it prints some variables.
Could someone help me with this problem?
Thanks in advance.

回答 (2 件)

Sayyed Ahmad
Sayyed Ahmad 2021 年 7 月 2 日

Walter Roberson
Walter Roberson 2021 年 7 月 2 日
When you system() or unix() then matlab does not use a login shell, so some initialization might not be done. Aliases might not be set up for example.
Also because it is not a login shell, your shell PATH and LD_LIBRARY_PATH or DYLD_LIBRARY_PATH might not have been set the way you expect.
You might need to
export VARIABLE=VALUE bash /s/test2.sh
or something like that

カテゴリ

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

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by