I would sugest looking at http://pexpect.sourceforge.net/ The Expect metalanguage was specifically designed for the kind of things you are trying to do. I used it recently on a project to configure 25 instances of an application, remotly, half over ssh half over telnet.
-- http://mail.python.org/mailman/listinfo/python-list