Matlab system command doesn't work properly on linux platform
Show older comments
When execute system('hostname -s') -command in matlab, process go to linux command line and in linux command line making exit command, process will go back to matlab command line with hostname.
Example run:
>> system('hostname -s')
[j...al@oulng208 users3/j...al]$exit
exit
oulng208
ans =
0
>>
Why matlab goes to linux command line? It should stay in matlab.
2 Comments
Rik
on 22 May 2020
What do you mean? The purpose of the system function is to call the OS command line.
Janne Karjalainen
on 22 May 2020
Answers (2)
Rik
on 22 May 2020
If you want to capture the output to a Matlab variable, you should use the second output:
[status,response]=system('hostname -s');
I don't have Matlab installed on my Ubuntu VM, but this works in Octave, so it should do the trick.
Walter Roberson
on 22 May 2020
0 votes
https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html
You have a BASH_ENV or equivalent for your shell, that is triggering interactive execution for the non-interactive case.
Hypothetically there could also be issues if you have SHELL environment variable set to include flags that should not be set for non-interactive work.
1 Comment
Janne Karjalainen
on 22 May 2020
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!