
14
In order to automate Echola’s Layer 1 switches you would need to write Tcl/Expect based scripts
or Perl/Xml based scripts (both example scripts are given below)
. The tcl and expect scripting
languages are easy to learn. We have given an example script written for fc811/FC811 at the end
which you can modify to suit your need. There are tons of online sources for learning tcl & expect.
The following provides quick high level overview of tcl and expect
http://cplug.org/t/uploads/2009/02/tcl-expect.pdf. There is a good book from O’Reilly which
provides great insight into expect language itself: “Exploring Expect: A Tcl-based Toolkit for
Automating Interactive Programs (Nutshell Handbooks)”.
Running scripts from Unix/Linux systems
If you want to run the script from a Unix/Linux based machines then there is possibility that you may
be already having these tools on your system. Check if it’s already been installed by typing “expect”
from Unix/Linux prompt. If it is not then you will have to install it using package install tool for that
particular flavor of Unix/Linux. For instance, on Fedore core Linux, you can use “yum install tcl
expect” to install tcl and expect.
Running scripts from Windows
For windows based systems you can install windows free community version of ActiveTcl from
Activestate http://www.activestate.com/activetcl/downloads. The expect is not available yet for
64bit version of Windows 7/Vista. So you will need to download 32bit version for ActiveTcl first and
then make sure to install “expect” using command “teacup install Expect”.
Also you need to enable “telnet” client on Windows before running any scripts. In order to enable
telnet on Windows follow these steps
Start
Control Panel
Programs And Features
Turn Windows features on or off
Check Telnet Client
Hit OK
After that you can start Telnet via Command Prompt to check if it works.
The following sample script actually login into FC811/fc811 switch and issue a switch command then
check whether the switch command was successful and return the result before terminating the
telnet session. This script takes argument (port number and state of the port (on/off)) from
commands line argument. Cut and Paste the following script on to any editor and save as “rosctl”.
Then you can run the script by issuing rosctl -p <port#> on|off. For instance, to switch port 2 to ON,
you can call script as rosctl -p 2 on. Make sure you have proper path set for expect on first line
“#!/usr/bin/expect” for Unix/Linux based systems. For windows you will have to uncomment ‘ exec’
Automating Echola’s Optical Switches
Содержание FC811
Страница 10: ...10 delete all groups in the database...
Страница 12: ...12...
Страница 18: ...18 Terminate telnet send exit r...