#!/bin/sh
update_fb() {
source_url="https://www.facebook.com/cutespring"
url="http://api.facebook.com/restserver.php?method=links.getStats&urls=$source_url"
num="`wget -O - $url 2>/dev/null | grep total | sed -e 's/^[ ]*<total_count>\([0-9][0-9]*\).*/\1/g'`"
xnum=$((0 + num))
if [ "$xnum" -gt 0 ]; then
echo "updating $xnum"
echo "$xnum." >/dev/ttyACM0
echo "$xnum." > &2
ret=$?
fi
}
check_network_connectivity () {
run=1
while [ $run -eq 1 ]; do
ping -c 1 168.95.1.1
run=$?
done
}
# main
check_network_connectivity
while [ 1 ] ; do
update_fb
sleep 5
done
-----
Commented by coopermaa:
Save above code as fb.sh, then run as follows:
$ ./fb.sh 2> /dev/ttyACM0