Splitting QUERYSTRING with sed

Working on a shell script where in the Query_String I need to separate one of the strings into two. For an example, my string has router=bras1+dallastx and I need to separate bras1 and dallastx into different variables. The DOMAIN variable works but I can not get the CISCO variable going. Any suggestions?

Here is my url that feeds the script:

http://mywebpage/syslog.cgi?router=router1+dallastx&month=01&day=01&string=security
 
NAME=`echo "$QUERY_STRING" | sed -n 's/^.*router=\([^&]*\).*$/\1/p'`
for opt in $NAME; do
CISCO= `echo $NAME | sed 's/+/ /g' | awk '{print $1}'`
DOMAIN=`echo $NAME | sed 's/+/ /g' | awk '{print $2}'`
done
#! /bin/bash

var="router=bras1+dallastx"
pos=`expr index $var =`
test=${var:$pos}
part1=${test%+*}
part2=${test#*+}
echo $part1 $part2

Thanks SKMDU for the suggestion. Unfortunatley, I tried but it did not work for what I am doing. The router= string will change each time.

Do you mean = wont be there?

I get this from a test

 
#! /bin/bash
var="router=bras1+dallastx"
pos=`expr index $var =`
test=${var:$pos}
part1=${test%+*}
part2=${test#*+}
echo $part1 $part2
# chmod 755 test123.cgi
# ./test123.cgi
expr: syntax error
router=bras1 dallastx

Try this:

var="router=bras1+dallastx"

CISCO=$(echo "$var" | awk -F[=+] '{print $2}')
DOMAIN=$(echo "$var" | awk -F[=+] '{print $3}')

With sed:

CISCO=$(echo "$var" | sed 's/.*=\(.*\)+.*/\1/')
DOMAIN=$(echo "$var" | sed 's/.*+//')

Thanks Franklin52, I used your sed method to solve this.

How to set variables using QUERY_STRING ?
When you are using eval ex. in cgi scripts, then you must check the string before using eval. ";&<>|\ ... and variable name is not ex. PATH and so on ...
Eval is nice, but eval is also dangerous, if you not check string before eval.
This ex. not include testing.

#!/someposixsh
QUERY_STRING="router=router1+dallastx&month=01&day=01&string=security"
# parse values to the array using delimiter &
IFS="&" values=( $QUERY_STRING )

for paramstr in ${values[@]}
do
        # add " " around the value
        paramstr="${paramstr/=/=\"}\""
        echo "$paramstr"
        # set variable
        eval $paramstr
done
echo "router:$router"
echo "month:$month"

Hi numele,

Sorry, I don't mean to be harping on PHP too much these days, but FYI, if you wrote your script in PHP, you then get all the web query variables "for free" in the $_GET[] superglobal variable available to all PHP scripts.

$router=$_GET['router'];
$month=$_GET['month'];

etc.

Then, you simply explode your $router string with explode()