can't redirect stderr in bash

Consider:

#!/bin/sh
#this is a shell script in sh (bourne)
grep missingfile 2>errout.txt

It works from the command line, but keeps producing errors from the script. So how do I redirect in a bash shell...or bourne?

you are doing the correct thing, make sure no spaces between 2 & the >

2>filename

are you sure you are not seeing stdout?

The usage of grep is

grep patttern filename

I couldn't see the pattern in the lines you have pasted

Does your grep support the "-q" option?