Skip to content

Instantly share code, notes, and snippets.

@stoyanovgeorge
Last active August 20, 2018 10:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stoyanovgeorge/01d97811c29e9e1d19f36a7398e9bad8 to your computer and use it in GitHub Desktop.
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
#!/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