open Linux Konsole from Matlab

6 ビュー (過去 30 日間)
Andreas Schwager
Andreas Schwager 2021 年 7 月 27 日
コメント済み: Andreas Schwager 2021 年 7 月 27 日
Hello,
on Ubuntu 18.04 shell typing
konsole &
a new window with console opens, as expected.
In Matlab typing
[status, cmdout] = system('konsole &', '-echo')
nothing happens...
The output is:
status =
0
cmdout =
0×0 empty char array
How to open a new console in a new thread from Matlab?
How to hand over even parameters or commands into this new console?
Executing e.g.
[status, cmdout] = system('jedit &', '-echo')
runs as expected. jedit opens and can be operated as usual.
Thanks for your answers
  5 件のコメント
Raymond Norris
Raymond Norris 2021 年 7 月 27 日
Just to clarify a term, system will launch a separate process, not thread. Agreed, it ought to run on a different core than MATLAB, but you could also imagine that MATLAB sees all cores (or at least many of them) and is spawning computation threads (i.e. maxNumCompThreads) on them. Since you're calling system and and not formally scheduling the process, it could be hit or miss.
I don't think you want to call xterm. But you might need to set the LD_LIBRARY_PATH before launching your app. For example:
[status,cmdout] = system('export LD_LIBRARY_PATH=/path/to/lib1_dir:/path/to/lib2_dir && rviz rviz -d runMyRvizLaunchFile.rviz');
disp(['cmdout: ' strtrim(cmdout) ' status: ' num2str(status)])
3 comments:
  1. Are you sure you're actually running into an issue? The system status comes back as 0.
  2. Not sure why the system call is calling rviz twice, but I assume you understand why. Seems like you'd only call it once.
  3. Notice I'm using strtrim, instead of cmdout(1:end-1), as the second output of system (cmdout) can have leading new lines as well.
Andreas Schwager
Andreas Schwager 2021 年 7 月 27 日
Thanks! This works!

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

採用された回答

Bjorn Gustavsson
Bjorn Gustavsson 2021 年 7 月 27 日
From the man-page of xterm I get this suggestion:
-e program [ arguments ... ]
Which should be applicable to your case?
HTH
  1 件のコメント
Andreas Schwager
Andreas Schwager 2021 年 7 月 27 日
Thanks

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGetting Started with Microsoft .NET についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by