system('wsl sudo ...') does not work

3 ビュー (過去 30 日間)
Francesco Bellelli
Francesco Bellelli 2022 年 6 月 15 日
回答済み: Francesco Bellelli 2022 年 6 月 16 日
Hi, i'm trying to write a script that executes a few command through wsl on Windows (basically to automatic install libraries from apt and a c++ routine with ./configure and make).
When I use command such as
system('wsl ./configure')
it goes well, but when I use some like
system('wsl sudo apt-get install')
the script runs but never ends (I see always the "pause" button).
Any suggestions on how to fix this? Thanks
  4 件のコメント
Rik
Rik 2022 年 6 月 16 日
The double layer is apparently a problem. Could there be a way to pipe the password in somehow? That would require you to store the password in a Matlab variable, but I don't really see a way around that myself. (you can use the input function if you don't want to store the password in plain text in your m file)
Walter Roberson
Walter Roberson 2022 年 6 月 16 日

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

回答 (1 件)

Francesco Bellelli
Francesco Bellelli 2022 年 6 月 16 日
It seems to work now by taking as input from the user his password and then using
system(wsl echo <password> | wsl sudo -S <command>)

カテゴリ

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

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by