#! /usr/bin/env bash function user_quit() { exit 0 } trap 'user_quit' SIGINT function die() { echo "$@" exit 1 } function check_connection() { if [ -z $LAN_SERVER ]; then die "Set \$LAN_SERVER, then rerun" fi if [ -z $WAN_SERVER ]; then die "Set \$WAN_SERVER, then rerun" fi local lan_server=$LAN_SERVER local wan_server=$WAN_SERVER for i in {1..100}; do # 10 + 2 pings = 12 seconds, # every fifth time means every minute print date before continuing if [[ $((var % 5)) -eq 0 ]]; then date fi ping -c 2 $lan_server ping -c 10 $wan_server done } check_connection