Skip to content
knipknap edited this page Sep 13, 2010 · 20 revisions

Automating Telnet and SSH

Exscript is a Python module and a template processor for automating network connections over protocols such as Telnet or SSH. We attempt to create the best possible set of tools for working with Telnet and SSH.

The Python Module

def hello_exscript(conn):
    conn.execute('ls -l')
    eval_file(conn, 'mytemplate.txt', foo = 'bar')

# Exscript can log into multiple hosts at the same time, no extra effort required.
quickrun(['localhost', 'anotherhost'],
         autologin(hello_exscript),
         max_threads = 5)

For more information please have a look at the API documentation. There is also a chapter in der PDF handbook.

Exscript is an excellent and much more powerful Net::Telnet replacement, so we welcome all you Perl developers!

The Template Language

The Exscript template language is in some ways comparable to Expect, but has unique features that make it a lot easier to use and understand for non-developers.

show version {extract /^(cisco)/ as vendor}
{fail "not a cisco router" if vendor is not "cisco"}

show ip interface brief {extract /^(\S+)\s/ as interfaces}
configure terminal
{loop interfaces as interface}
  interface $interface
   description This is an automatically configured interface description!
   cdp enable
   no shut
  exit
{end}
copy running-config startup-config

To get going quickly, have a look at A Short Overview For The Impatient. You may also look at our Examples.

For more documentation, please have a look at the Documentation page.

Requirements

Exscript requires the following software:

  • spiff-signal
  • Python 2.2 or greater
  • Python-crypto
  • Python-pexpect (optional, for SSH support)
  • ssh (optional, for SSH support)

Exscript has been tested on the following operating systems:

  • Linux
  • Solaris
  • AIX
Clone this wiki locally