I have a simple script.
# test.sh read -p ">> " user read -p ">> " -n1 yes echo echo "user: $user" echo "yes: $yes"
When executed as
bash test.sh it prompts to input values and stores them in variables
yes. So output is like this
user@host:~/static/dcc$ bash test.sh >> foo >> b user: foo yes: b
However when cat test.sh is piped to bash, it doesn't work, instead, read eats everything after it and stores it in
user variable as it seems (doesn't prompt for input).
user@host:~/static/dcc$ cat test.sh | bash user: read -p ">> " -n1 yes yes:
Using process substitution works fine, however not if bash is run as sudo (which is what i need)
user@host:~/static/dcc$ bash <(cat test.sh) >> user >> y user: user yes: y user@host:~/static/dcc$ sudo bash <(cat test.sh) bash: /dev/fd/63: No such file or directory
In real world example, I'm trying to get script from web using curl and to run it as with sudo. I would like to avoid additional step of downloading the script first if at all possible.