Exscript

2.1 GPL (GNU General Public License)    
3.5/5 19

  1,118 downloads

A scripting language for automating network connections over protocols such as Telnet or SSH.

description

download

specs

changelog

1 comment

Exscript is a scripting language for automating network connections over protocols such as Telnet or SSH. Exscript is in some ways comparable to Expect, but has some unique features that make it a lot easier to use and understand for non-developers.

Exscript is written in Python and we value componentized, clean code, so it will always be easy to modify and extend.

Quick Introduction

With Exscript you can quickly automate a conversation with a device over Telnet or SSH. For example, to execute the "ls" command on three different hosts, create a file with the following content:

ls

and then run it using

./exscript.py my_template host1 host2 host3

Talking To Multiple Devices At The Same Time

With Exscript you can automatically parallelize your connections, such that multiple sessions are opened at the same time. This can speed up the time in which a specific command is propagated within your network.

For example, imagine you want to execute the clear ip bgp * soft in command on twenty different Cisco routers. Start by creating a text file with the following content:

clear ip bgp * soft in

Save this file as commands.exscript. Also, create a text file that contains the list of hostnames to which the command should be sent:

host1
host2
...
host20

Save this file as hosts.txt. To send this change to all routers at the same time, type the following command:

./exscript.py --hosts hosts.txt -c15 commands.exscript

Note that the -c15 option causes Exscript to open a maximum of fifteen connections at the same time. Once the first host out of these 15 is completed, Exscript opens the connection to the next host, until the clear ip bgp * soft in command has been sent to all hosts.

Advanced Command Templates

Exscript templates support many more commands. For example, to automate a session with a Cisco router, the following template may be used:

show version {extract /^(cisco)/ as vendor}
{if vendor is "cisco"}
show ip interface brief {extract /^(S+)s/ as interfaces}
{loop interfaces as interface}
show running interface $interface
configure terminal
interface $interface
no shut
end
{end}
copy running-config startup-config
{end}

For a full overview over the template language, look at this page.

Error Handling

Exscript comes with excellent error handling for free, without adding any extra code into the templates.

Command Line Options

You can pass parameters (or lists of parameters) into the templates and use them to drive what happens on the remote host. Exscript easily supports logging, authentication mechanisms such as TACACS and takes care of synchronizing the login procedure between multiple running connections.
read more   
Last updated on March 11th, 2011

#scripting language #Expect clone #Linux interpreter #scripting #language #Expect #development

ExscriptExscript

1 User review so far. Load top Load all

SUBMIT