Exscript is a Python module and a template processor for automating network connections over protocols such as Telnet or SSH. There are two ways for using Exscript:
Exscript supports logging, reporting, templates, emulators, config file handling, and many more tools for sysadmins. The Python module even comes with an integrated Telnet server and SSH2 server, so you can easily test your Telnet or SSH script against an emulated device!
Here are some starting points for more info: