I have a script which runs the command
apt-get update but the script is unable to detect failure due to no internet.
apt-get is not run with root privileges it exits with
so I can do a check like
if apt-get update then echo "success!" else echo "something went wrong fi
apt-get update is run without an internet connect, it produces error messages, some to STDOUT, some to STDERR, e.g.
this goes to STDERR
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/InRelease
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/trusty-security/InRelease
This goes to STDOUT
... Err http://archive.ubuntu.com trusty-updates Release.gpg Temporary failure resolving 'archive.ubuntu.com' Ign https://deb.nodesource.com trusty InRelease Ign https://deb.nodesource.com trusty Release.gpg ...
But ultimately it still returns an exit of
How can I detect an
apt-get upgrade failure caused by no internet access?