Send password : In Background

Hi All,

How to pass the password in background.....?

" /usr/bin/hdiutil attach -mountroot -stdinpass /path/to/mount/
/path/of/image/TEST.sparseimage "

The above command asks the password to mount a sparse image and when
supplied it gets mount. But my requirement is to use this command within
a shell script to mount the sparse image, and I don't want to store the
password in key chain file. How I would pass the password to this command
to mount the sparse image......?

Please suggest me...

You may need to use tools such as "expect" to handle this