Skip to content

Instantly share code, notes, and snippets.

@morgaine
Created December 1, 2012 14:17
Show Gist options
  • Save morgaine/4182524 to your computer and use it in GitHub Desktop.
Save morgaine/4182524 to your computer and use it in GitHub Desktop.
Example snippet showing use of shell to display ping status on LEDs
#! /bin/sh
LED_CONTROL_CMD="switch_led"
LED_CONTROL_CMD="echo"
BASE_LED_NUMBER="5"
INTERVAL="30"
HOSTS="
google.com
slashdot.org
no-such-host.net
"
while true
do
LED_NO="$BASE_LED_NUMBER"
for TARGET in $HOSTS
do
if ping -n -c 1 $TARGET >/dev/null 2>&1
then
"$LED_CONTROL_CMD" "$LED_NO" 1
else
"$LED_CONTROL_CMD" "$LED_NO" 0
fi
LED_NO=$(($LED_NO + 1))
done
sleep "$INTERVAL"
done
@jahanzeb07
Copy link

Hi, I think somebody already should have found complete solution for this. I am also doing a project in which I required similar functionality but couldn't figure out how it will be done. Please post the complete solution. Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment