Matlab on linux, "system" command not working

9 ビュー (過去 30 日間)
JohnDapper
JohnDapper 2016 年 2 月 10 日
編集済み: Walter Roberson 2016 年 2 月 10 日
Hi all. I am running MATLAB 2012b on linux. I have a bunch of executables/shell scripts in a folder which is added to the MATLAB path. Essentially, I can run, from MATLAB, "system(program.exe)" which works fine. But "system(script)" does not work.
From the command prompt, both "program.exe" and "script" work fine. What's going on here? Why does the system command work for executables but not scripts?
Cheers
  2 件のコメント
Walter Roberson
Walter Roberson 2016 年 2 月 10 日
編集済み: Walter Roberson 2016 年 2 月 10 日
To check, do the scripts have their executable bit set? Do they use #! ( shebang) syntax? If they do, what shell do they name? What is your $SHELL ?
Thomas Blazek
Thomas Blazek 2016 年 2 月 10 日
編集済み: Thomas Blazek 2016 年 2 月 10 日
First, make sure you are getting the path right. Your syntax works only if the script lies in on of the special $PATH folders. Otherwise, you have to provide the path, relative or absolute.
Furthermore, be careful with quotes and syntax. You have to write either
>> system('./script.sh')
or
>> system ./script.sh
or even better, specify the shell as Walter Roberson mentioned:
>> system('bash ./script.sh')
(replace bash with the shell of your choice)

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by