how to use expect with bash

view story

http://askubuntu.com – I Have created a shell script as given below.This script will login to a remote server as a normal user then switch to root user for creating a directory.The script is as given below. ssh -t [email protected] ' su root -c " echo \"Give Directory name :\"; read dir; mkdir \$dir; "; ' Here the script will ask Password for normal user first.Then again it will ask for root Password.How could I automate this using expect command.I want to supply the password automatically for the root user only.I think it can be done with expect. Please do help me. (HowTos)