--- /dev/null
+#!/bin/sh
+
+usage() {
+ cat << EOF
+Usage:
+ $0 [OPTIONS]
+ $0 -h
+ $0 -c "echo 'online'"
+
+OPTIONS:
+ -h Show this text
+ -c CMD Command to execute if online
+EOF
+}
+
+CMD=""
+
+while getopts "hc:" OPTION; do
+
+ case "$OPTION" in
+ h)
+ usage
+ exit
+ ;;
+ c)
+ CMD=$OPTARG
+ ;;
+ esac
+done
+
+if [ -z "$CMD" ]; then
+ echo "No command given."
+ usage
+ exit 2
+fi
+
+if ping -c1 8.8.8.8 2>&1 >/dev/null; then
+ $CMD
+fi