Hi,
I am creating a script that collects data from remote routers and reports this back to a central location. I do however have a problem with constructing the URL that shall be reported back because the global variable WGET which is used to build the string that shall be reported back is not treated as global, but is only updated locally within the loop:
Code:
#!/bin/sh
WIFI=ath0
BR=br0
# Update the MAC, IP address and peers of the AP
WGET=http://<mysite>/update2.php
IP=`ifconfig $BR | grep inet | cut -d B -f1 | sed s/[^0-9.]//g`
AP=`iwconfig $WIFI | grep Access | cut -d" " -f18`
ESSID=`iwconfig $WIFI | grep ESSID | cut -d\" -f2`
RATE=`iwconfig $WIFI | grep Rate | cut -d"M" -f1 | cut -b20-25 | cut -d" " -f1`
UPTIME=`cat /proc/uptime | cut -d"." -f1`
CLI=`cat /proc/net/arp | grep $BR | wc -l | sed s/[^0-9]//g`
WGET="$WGET?IP=$IP&AP=$AP&ESSID=$ESSID&UPTIME=$UPTIME&CLI=$CLI&RATE=$RATE"
echo $WGET
iwlist $WIFI peers | grep 'Quality' | while read line;
do
MAC=`echo $line | cut -d" " -f1`
QUAL=`echo $line | cut -d"=" -f2 | cut -d"/" -f1`
SIG=`echo $line | cut -d"=" -f3 | cut -d" " -f1`
NOISE=`echo $line | cut -d"=" -f4 | cut -d" " -f1`
WGET="$WGET&MAC[]=$MAC&QUAL[]=$QUAL&SIG[]=$SIG&NOISE[]=$NOISE"
echo $WGET
done
echo $WGET
#wget -O /dev/null "$WGET"
If you run the above script, the local WGET within the loop is updated and shows the complete URL with all peers, but the last WGET is not getting updated with the contents within the loop.
What can be done to update the WGET so it contains info from all peers?
BR
Arne-J.