Piping a script with "read" to bash
read
reads from standard input. But the standard input of the bash process is already taken by the script. Depending on the shell, either read
won't read anything because the shell has already read and parsed the whole script, or read
will consume unpredictable lines in the script.
Simple solution:
bash -c "$(wget -O - http://example.com/my-script.sh)"
More complex solution, more for education purposes than to illustrate a good solution for this particular scenario:
echo '{ exec </dev/tty; wget -O - http://example.com/my-script.sh; }' | bash
Process substitution will do what you want:
bash <(wget ...)
That said, I have to question your motivation here. If you control the webserver (and use https) then maybe this might make sense. But just running a script from the internet blind is very risky.