実現したいこと
ubuntu22.04にrustなどをインストールするのをシェルを使って自動化したい
発生している問題・分からないこと
xdotool key Return | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
と書いても、press enterが自動化できず、以下のように表示されてしまう。
// 省略
default host triple: x86_64-unknown-linux-gnu
default toolchain: stable (default)
profile: default
modify PATH variable: yes
- Proceed with standard installation (default - just press enter)
- Customize installation
- Cancel installation
該当のソースコード
shell
1cd $home 2yes | sudo apt-get update 3yes | sudo apt-get upgrade 4yes | sudo apt-get install libssl-dev libudev-dev pkg-config zlib1g-dev llvm clang cmake make libprotobuf-dev protobuf-compiler xdotool 5xdotool key Return | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh 6source $HOME/.cargo/env 7rustup update 8cargo --version 9rustc -V
試したこと・調べたこと
- teratailやGoogle等で検索した
- ソースコードを自分なりに変更した
- 知人に聞いた
- その他
上記の詳細・結果
xdotool key KP_Enter | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
としたり、curlの次の行に書いたりしてみたが、うまくいかない。
補足
特になし
https://sh.rustup.rs の中身を確認してみると、-y オプションでプロンプトを無効にすることができます。("Proceed with standard installation" を選択するのと同じで、すべてデフォルトの設定でインストールが進みます)
Options:
-y
Disable confirmation prompt.
なので、bash(1) の -s オプションを利用して、上記の -y オプションを渡すとよいかと思います。
-s
If the -s option is present, or if no arguments remain after option processing, then commands are read from the standard input. This option allows the positional parameters to be set when invoking an interactive shell or when reading input through a pipe.
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | /bin/bash -s -- -y
頂いた内容で解決しました!大変ありがとうございます!!!

回答1件
あなたの回答
tips
プレビュー