thesilence
New Around Here
Hi, my apologies if I'm in the wrong section. I'm wondering if there is a repository of helper scripts to parse common (or not so common) nvram settings and output them in an easy to parse way for larger scripts, or just for quick command-line reference? A quick search says no but I'm hopeful
Assuming there isn't, here is my first jab at something useful (feel free to use/modify/throw out the window), or add your own to the thread if you like.

Code:
#!/bin/sh
# apg_info.sh
# print entry, index, bridge, vlan, vlan rule, enabled, ssid for each guest network
printf "Entry#\tIdx#\tBridge\tVLAN#\tVLANRul\tEnabled\tSSID\n"
for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18; do
SSID=`nvram get apg$i'_'ssid`
if [ "$SSID" != "" ]; then
IDX=`nvram get apg$i'_'security|sed 's/^.*[^0-9]\([0-9]*\)$/\1/'`
VL=`nvram get apg_br_info | tr '<' '\n' | awk -F'>' '{print $1 ":" $2}'|grep "$i:"|cut -f1 -d':'`
BRG=`nvram get apg_br_info | tr '<' '\n' | awk -F'>' '{print $1 ":" $2}'|grep "$i:"|cut -f2 -d':'`
EN=`nvram get apg$i'_'enable |sed 's/1/y/g; s/0/n/g'`
VLR=`nvram get vlan_rl|tr '<' '\n'|awk -F'>' '{print $1 ":" $2}'|grep ":$VL"|cut -f1 -d':'`
if [ "$VL" == "" ]; then VL="-";VLR="-";fi
if [ "$BRG" == "" ] && [ "$EN" == "y" ]; then BRG="br0";fi
printf "$i\t$IDX\t$BRG\t$VL\t$VLR\t$EN\t$SSID\n"
fi
done