how to call system WSL to run executable on ubuntu
4 views (last 30 days)
Show older comments
Dear Community!
I am working with MATLAB R2023a on Windows 10.
Recently, I have been compiling and running an executable (hydrological model) within WSL on Ubuntu 22.04.2 LTS (the executable cannot be compiled on Windows machines).
Now, I need to run the executable n times to carry out a sensitivity analysis. I have a script that runs in MATLAB.
I could install MATLAB also on Ubuntu and that is an easy solution for my task.
What I do not know how to do it, and for this I would really appreciate your help in the simplest words possible, is to call the executable that runs on WSL from the MATLAB Command Window.
I have looked for solutions in many forums but with no luck. As a trial, from this link "https://it.mathworks.com/matlabcentral/answers/473127-how-to-pipe-redirect-output-of-a-command-in-windows-subsystem-for-linux-wsl-to-another-using-a-sys" I ran
system('wsl bash -c "ls /mnt/c/ | tail -n 1"')
and I got
W
ans =
-1
as well as
system('bash -c "ls /mnt/c/ | tail -n 1"')
and I got
Windows Subsystem for Linux has no installed distributions. Distributions can be installed by visiting the Microsoft Store: https://aka.ms/wslstore
ans =
1
So the first did not work, and the second asked to install a Linux distribution, although I have it.
Any experience to make it work?
6 Comments
Shivang
on 6 Oct 2023
Hi Daniele,
As you were able to run commands directly in the Linux shell as well as the Windows Command shell, the problem might be related to your MATLAB setup.
I would suggest contacting MathWorks support and creating a Technical Support request for further assistance: https://www.mathworks.com/support/contact_us.html
Best, Shivang
Answers (0)
See Also
Categories
Find more on Introduction to Installation and Licensing 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!