1

I have read the answers in this post but it doesn't seem to work for my problem.

I am executing a bash script via stdin from wget:

wget -O - http://serverip/subfolder/script | sudo bash

I've tried using apt-get -y --force-yes install <packages..> || true, but it still exits the script if the one of the listed is installed by apt-get.

It doesn't exit the script if all the listed packages are already installed.

The same thing happens if I have a apt-get upgrade and it installs package(s). It will exit the script.

I have another set of scripts, that seems to work. In that scenario, the install script is just a stub, that downloads, runs the script via bash <scriptname> then deletes the script. The script itself will elevate its privilege by sudoing itself. apt-get works as expected here.

Any insight as to how to prevent apt-get from terminating the script would be appreciated.

2 Answers 2

6

I wish people would stop doing: wget | bash. It's just silly, and has unintended effects like the one here. You have bash, so make use of its features. In particular, process substitution:

bash <(wget -O - http://serverip/subfolder/script)
0
4

You probably just need to stop apt-get from greedily reading the standard input. Do this by redirecting stdin to /dev/null, a file that returns eof to reads. Eg:

apt-get -y --force-yes install ... </dev/null

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .