I have a script which runs the command apt-get update but the script is unable to detect failure due to no internet.i.e. if apt-get is not run with root privileges it exits with code 100.so I can do a check likeif apt-get updatethen    echo success!else    echo something went wrongfiBut if 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 InReleaseIgn https://deb.nodesource.com trusty Release.gpg...But ultimately it still returns an exit of 0.How can I detect an apt-get upgrade failure caused by no internet access? 
How can I detect when apt-get update fails due to no network connection?
apt