#!/bin/sh # ############################################################################################ # # Project: Beabloo # # Script: Search Surrounding CGI # # Author: Oscar Herrera # Date: 2008-12-04 # ############################################################################################ # # # Variables APP_DIR="/opt/beabloo" HCI_ROL_FILE=${APP_DIR}/data/rol_devices initContentType(){ echo "Location: http://www.beabloo.com/BeablooWeb/faces/SearchSurrounding.jsp?from=${MAC_MASTER}&to=$to&lang=$lang" echo "Content-type: text/html" echo "" echo "" } parseParameters(){ i=1 end=false echo ${QUERY_STRING} > /tmp/debug.out while [ "$end" = "false" ] do line=`echo ${QUERY_STRING} | cut -d'&' -f $i` echo "line: $line" >> /tmp/debug.out if [ "$line" = "${QUERY_STRING}" -o "$line" = "" ] then end="true" fi var=`echo $line | cut -d'=' -f1` echo "var: $var" >> /tmp/debug.out value=`echo $line | cut -d'=' -f2` value=`echo "$value" | sed 's/\([A-Za-z0-9_]*\).*/\1/'` echo "value: $value" >> /tmp/debug.out if [ "$var" != "" ] then eval $var="$value" fi i=`expr $i + 1` done } # --------------------------------------- # Main # --------------------------------------- HCI_MASTER=`grep master ${HCI_ROL_FILE} | awk -F";" '{print $1}'` MAC_MASTER=`hcitool dev | grep ${HCI_MASTER} | awk '{print $2}'` parseParameters initContentType