ExpectJ is a Java implementation of the Unix expect utility. ExpectJ provides a Unix expect like support to write Java Programs that communicate with other programs and perform some operation on them. Download from http://expectj.sf.net.
ExpectJ is key to my software's success DatacenterManager on java-apps.org There's still one thing that's missing and that is regular expressions. Due to lack of ExpectJ regex support DatacenterManager can't match ver well and need to await the timeout set within ExpectJ and still find out the output matched. This greatly reduces the performance of any tool using ExpectJ. I would be very grateful if ExpectJ would support Regex matches!
Works fairly well, and easy to extend.
The built in telnet and ssh (using jsch) features are working well for me in my current project that issues various router queries.