Curl in non-interactive mode

command linecurlscripting

I am trying to automate stuff which includes installing rust through

curl https://sh.rustup.rs -sSf | sh . 

This is interactive and queries for user-input to choose from i.e. "1" "2" or "3".

I am not able to figure out how to input values automatically.

For example with apt-get, there is a -y option try to capture and input for prompt.

Not sure, how it is done for curl.

Best Answer

Checking the script file, you can use the -y option:

% sh <(curl https://sh.rustup.rs -sSf) -h
rustup-init 1.18.3 (302899482 2019-05-22)
The installer for rustup

USAGE:
    rustup-init [FLAGS] [OPTIONS]

FLAGS:
    -v, --verbose           Enable verbose output
    -y                      Disable confirmation prompt.
        --no-modify-path    Don't configure the PATH environment variable
    -h, --help              Prints help information
    -V, --version           Prints version information

OPTIONS:
        --default-host <default-host>              Choose a default host triple
        --default-toolchain <default-toolchain>    Choose a default toolchain to install
        --default-toolchain none                   Do not install any toolchains

To add -y as an argument in that pipeline, use sh's -s option:

curl https://sh.rustup.rs -sSf | sh -s -- -y

-s tells sh to read commands from input, and -- passes the remaining arguments to the script (read from input), so -y is set as an argument to the script.

Or, if you have bash, use process substitution:

sh <(curl https://sh.rustup.rs -sSf) -y
Related Question