Last active
August 20, 2018 10:46
-
-
Save stoyanovgeorge/01d97811c29e9e1d19f36a7398e9bad8 to your computer and use it in GitHub Desktop.
Check whether a host is replying to ICMP requests or not. Usage: ./script.sh 192.168.1.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 | |
# check if the $1 is empty | |
if [[ -z "$1" ]];then | |
printf "Please define the IP or the hostname which you want to check!\nUsage: ./script.sh 192.168.1.1\n" | |
else | |
if ping -c 1 "$1" &> /dev/null;then | |
printf "%s is UP!\n" "$1" | |
else | |
printf "%s is DOWN!\n" "$1" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment