The attached script can be run on an OpenVix box.
(It can be run on other Linux boxes if you edit the box setting at the top).
Code:
#!/bin/sh
#
box=127.0.0.1
# python -m json.tool fails on OpenVix as runpy isn't there.
# So we do it on long-hand...
#
parse_json() {
python -c '
import json
import sys
str = sys.stdin.read()
kv = json.loads(str)
print json.dumps(kv, sort_keys=True, indent=0, separators=(",", ":"))
'
}
# python will sort the fields...
#
wget -qO - http://$box/api/statusinfo | parse_json |
while read line; do
case $line in
*\"currservice_station\":*)
channel=`echo $line | sed -e 's/.*:\"//' -e s'/\",.*//'`
;;
*\"currservice_name\":*)
name=`echo $line | sed -e 's/.*:\"//' -e s'/\",.*//'`
;;
*\"inStandby\":*)
case $line in
*true*|*True*) echo "In standby" ;;
*) echo $channel: $name ;;
esac
exit
;;
esac
done