help needed in shell scripting......urgent

Dear friends,
please help me to solve following problem.

I'm running a frontend application from which i'll be invoking the shell script with arguments as given below

-driver -w -p "ABC XYZ" -S -ds con -dn "abc xyz"
i am getting
$1=-driver
$2=-w
$3=-p
$4="ABC
$5=XYZ"
$6=-S
$7=-ds
$8=con
$9=-dn
$10="abc
$11=xyz"

instead, i am expecting following output,
$1=-driver
$2=-w
$3=-p
$4="ABC XYZ"
$5=-S
$6=-ds
$7=con
$8=-dn
$9="abc xyz"

Please help me to get the correct output as mentioned above.

It's very urgent...........

Regards,
swamymns

You should really use getopts:

Link

if you can be flexible with the way you pass these arguments you can pass it as follows
-driver -w -p \"ABC XYZ\" -S -ds con -dn \"abc xyz\"

What OS/shell are you using? I tested the following code:

#!/usr/bin/xxx
echo first=$1 second=$2 third=$3

The xxx in the above was tested with ksh, sh and csh on HP-UX and it has worked as you want it to.

# ./test.sh 1 "2 3" 4
first=1 second=2 3 third=4