 <p>If you prefer/are stuck with bash, perhaps you are looking for <a href="http://linux.die.net/man/1/expect" rel="nofollow">expect</a>?</p> <p>More on that here: <a href="http://wiki.tcl.tk/11583" rel="nofollow">http://wiki.tcl.tk/11583</a></p>