airpoll: airport link status monitor
#!/bin/sh
#####################
#
# name: airpoll (airpoll.sh)
# vers: 0.2a
# date: 070806
# first: 042006
# auth: "Keith Beckman" <kbeckm@alphahelical.com>
# site: http://alphahelical.com/code/osx/airpoll
# desc: airpoll is a simple script which continuously monitors your
# AirPort link status. If there is a problem finding the airport
# command, try $> locate airport to find where the executable
# (located in the Apple80211.framework) lies, and put that path (sans
# the "airport" itself) in $air_path.
#
#####################
####configuration####
verstring='airpoll v0.2a 070806 Keith Beckman'
air_path='/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/'
interval=10
##end configuration##
ap_usage () {
echo "Usage: airpoll -[h|v] [-i interval]
airpoll continuously monitors your AirPort link status at the specified
interval (default is ten seconds).
-i|--interval sets number of seconds between status checks
-v|--version displays the version string
-h|--help displays this help text"
}
poll_airport () {
while [ 1 ]; do
${air_path}airport -I |\
grep linkStatus |\
cut -d ':' -f 2 |\
cut -d ' ' -f 2
sleep $interval
done
}
case $1 in
'-v'|'--version')
echo $verstring;
exit
;;
'-h'|'--help'|'-u'|'--usage')
ap_usage
exit
;;
'-i'|'--interval')
if [ $2 ]; then
interval=$2
else
echo "Please specify an interval when using the '-i' option."
exit
fi
;;
*)
esac
poll_airport
airpoll | Download Source | View Source