Open file with correct application

Can someone please help me with my bourne shell script. I am a struggling newbie. I need create a script that will read an argument from a command line, access a config file with application file types, and open the file with the correct application. The file needs to be able to handle file extensions like .c or .h and exceptions. My config looks like:

#This is a sample .dorc

Application/PostScript ps /usr/bin/ggv

and my current shell script:

#!/usr/bin/bash

filename=$(basename ${1})
echo $1
file_ext=${filename##*.}
echo $file_ext
line=$(grep $file_ext sample.dorc | cut -f3 $i)
$line $1

Thanks in advance for any help.

Not sure what you're looking for really, but he is my rewrite with an error check...

#!/usr/local/bin/bash
file_ext=${1##*.}
echo $file_ext
prog=$(awk -v ext=$file_ext '$2 == ext {print $3}' sample.dorc)
if [[ -n $prog ]] ; then
        echo $prog can run $1
else
        echo $1 not configured in dorc file
fi
exit 0

Thanks for your help. I tried your re-write but it gave me a command not found error. I'm sure I made a mistake somewhere. I'm really new at this. The purpose of my script is to basically perform the same functionality as a double click in windows. If I double click on a word file it opens in MS Word. My script should take the filename in the command line and open it with the correct application. I appreciate the help.

I still cannot get my script to work correctly. Additional help would be greatly appreciated. Should I use an awk command?