Re: Enter a password automatically w/ bash script? for complex interactive tools, the "expect" tool is probably the most powerful.
Otherwise for simple scripts you can do something like:
sudo umount /media/disk << eob
YOURPASSWORD
eob
(the eob just marks a "here" document ... can be any unique string) |