Created
May 6, 2022 06:54
-
-
Save vertexvaar/b3e64ba0201dcdd56bf90a9a2c68e533 to your computer and use it in GitHub Desktop.
Check if machine is connected to the internet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Taken from https://stackoverflow.com/a/44280885/2025722 | |
# Added more devices (mainly from docker) to excluded list | |
find /sys/class/net/ -maxdepth 1 -mindepth 1 ! -name "*lo*" ! -name "veth*" ! -name "br-*" ! -name "docker*" -exec sh -c 'cat "$0"/carrier 2>&1' {} \; | grep -q '1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Taken from https://stackoverflow.com/a/26820300/2025722 | |
wget -q --spider http://google.com | |
if [ $? -eq 0 ]; then | |
echo "Online" | |
else | |
echo "Offline" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment