#!/bin/bash if [[ "$#" != "3" ]]; then echo "Usage: ping.sh IP onsign offsign"; fi # Get the status STATUS="$(ping $1 -c 1 -w 2 | grep packets | sed "s/^.*tted, //;s/1/$2/;s/0/$3/;s/ re.*$//")" # Create the directory if [ ! -d ~/.conky/status ]; then mkdir ~/.conky/status; fi # Remove the old status if [ "$STATUS" == "$2" ]; then if [ -f ~/.conky/status/$1.$3 ]; then rm ~/.conky/status/$1.$3; fi else if [ -f ~/.conky/status/$1.$2 ]; then rm ~/.conky/status/$1.$2; fi fi # Create the new status file if [ ! -f ~/.conky/status/$1.$STATUS ]; then touch ~/.conky/status/$1.$STATUS; fi