Take a look at
expect if you are doing this on unix, and be very careful how you do passwords like this -- many times there are better solutions than pushing passwords to interactive execs. Maybe if you go into a little more deatail on what you want to do we can provide you with some alternatives.
-Waswas