All rights reserved. Pr inted in the USA. October 1998.
The information in this documen t is subject to change without notice. The statements, configurations, technical data,
and recomm endations in this document are believed to be accurate and reliable , but are presen ted without express or
implied warranty. Users must take full responsibility for their applications of any products specified in this document.
The information in this documen t is proprietary to Bay Networks, Inc.
The software described in this document is furnished under a license agreement and may only be used in accordance
with the te rms of that license. A summary of the Software License is incl uded in this document.
Trademarks
ACE, AFN, AN, BCN, BLN, BN, BNX, CN, FRE, LN, Optivity, PPX, Quick2Config, and Bay Networks are
registered tradema rks and Advanced Remote Node, ANH, ARN, ASN, BayRS, BaySecure, BayStack, BayStream,
BCC, BCNX, BLNX, EZ Install, EZ Internetwork, EZ LAN, FN, IPAutoLearn, PathMan, RouterMan, SN, SPEX,
Switch Node, System 5000, and the Bay Netwo rks logo are trademarks of Bay Networks, Inc.
Microsoft , MS, MS-DOS, Win32, Windows, and Windows NT are registered trade m arks of Microsoft Corporation.
All other trademarks and registered trademark s are the property o f their respective owners .
Restricted Rights Legend
Use, duplication, or disc losure by the United States Government is subject to restrictions as set forth in subparagraph
(c)(1)(ii) of the Rights in Technical Data and Computer Software clause at DFARS 252.227- 7013.
Notwithstanding any other license agreem ent that may pertain to, or accompany the delivery of, this computer
software, the rights of the United States Government regarding its use, reproduction, and disclosure are as set forth in
the Commercial Computer Software-Restricted Rights clause at FAR 52.227-19.
Statement of Conditions
In the interest of improving internal design, operational function, and/or reliability, Bay Networks, Inc. reserves the
right to make changes to the products described in this document wi thout notice.
Bay Networks, Inc. does not assum e any liability that may occur due to the use or application of the product(s) or
circuit layout(s) described herein.
SUCH PORTIONS OF THE SOFTWARE ARE PROVIDED “ AS IS” AND WITHOUT ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
In additi on, the program and information contained herein are licensed only pursuant to a license agreement that
contains restrictions on use and disclosure (that may incorpor ate by reference certain limitat ions and notices imposed
by thir d pa rt ie s).
ii
303563-A Rev 00
Bay Networks, Inc. Software License Agreement
NOTICE: Please carefully read this license agreement before copying or using the accompanying software or
instal ling the hardwa re unit with pre-enabled softw are (each of w hich is referred to as “Softw are” in this Ag reement).
BY COPYING OR USING THE SOFTWARE, YOU ACCEPT ALL OF THE TERMS AND CONDITIONS OF
THIS LICENSE AGREEMENT. THE TERMS EXPRESSED IN THIS AGREEMENT ARE THE ONLY TERMS
UNDER WHICH BAY NETWORKS WILL PERMIT YOU TO USE THE SOFTWARE. If you do not accept these
terms and conditions, return the product, unused and in the original shipping container, within 30 days of purchase to
obtain a credit for the full pur chase price.
1. License Grant. Bay Networks, Inc. (“Bay N etworks”) grants the end user of the Software (“Licensee”) a p ersonal,
nonexcl usive, nontransferable license: a) to use the Soft w are either on a single computer or, if applicable, on a si ngle
authori zed de vi ce ide ntified by host ID, fo r whi ch it was origi nal ly acq uired ; b) to cop y the Sof tw ar e so le ly for bac kup
purposes in support of authorized use of the Softwar e; and c) to use and copy the associated user manual solely in
support of authorized use of the Software by Licensee. This license applies to the Software only and does not extend
to Bay Networks Agent softwa re or other Bay Networ ks software products. Bay Networks Age nt software or other
Bay Networks software products are licensed for use under the terms o f the applicable Bay Networks, Inc. Software
License Agreement that accompanies such software and upon payment by the end user of the app licable license fees
for such software.
2. Restrictions on use; reservation of rights. The Software and user manuals are protect ed under copyright laws.
Bay Networks and/or its licensors retain all ti tle and ownership in both the Software and user manuals, including any
revis ions made by Bay Networks or its licenso rs. The copyright notice must be reproduced and included with any
copy of any por tion of the Sof tw are or use r manua ls . Licens ee may not modif y, transla te, dec ompi le , disas se mble , use
for any compe ti ti v e an al ysis, r e v erse e ngi ne er , dis tr ib ute , o r c rea te der i vative w ork s f ro m the Softw are or u se r man ual s
or any copy, in whole or in part. Except as expressly provided in this Agreement, Licensee may not copy or transfer
the Softw are or user manuals, in w h ole or in part. The Sof tw are and user manuals embody Bay Networks’ and its
licenso rs’ confidenti al and proprietary intellectual property. Licensee shall not sublicense, assign, or otherwise
disclos e to any third party the Software, o r any informatio n about the operation, design, performance, or
implementation of the Softw are and user manuals that is confi dential to Bay Networks and its lice nsors; however,
Licensee m ay grant permission to its consultants, subcontractors, and agents to use the So ftware at Licensee’s f acility,
provided they have agreed to use the Software only in accordance with the ter ms of this license .
3. Limited warranty. Bay Ne tworks warrants each item of Software, as delivered by Bay Netw orks and properly
installed and operated on Bay Ne tw orks hardware or other equipment it is origi nally licensed for, to function
substantially as described in its accompanying user manual during its warranty period, which begi ns on the date
Softwar e is fi r st shi pped to Licen see . If any it em of Soft war e fai ls to so func ti on du ring i ts warr anty pe ri od, as t he so le
remedy Bay Ne tworks will at its discretion provide a suitable fix, patch, or workaround for the problem that may be
included in a future Software release. Bay Networks further wa rrants to Licensee that the med ia on which the
Softwar e is provided will be free from defects in materials and workmanship under normal use for a period of 90 days
from the date Software is first shipped to Licensee. Bay Networks will replac e defective me dia at no charge if it is
returned to Bay Networks during the warranty period along with proof of the date of shipment. This warranty does not
apply i f the media has been damag ed as a result of accident, misuse, or abuse. T he Licensee as sumes all re sponsibility
for selection of the Software to achieve Licensee’s intended results and for the installation, use, and results obtained
from the Software. Bay Networks does not warrant a) that the functions contained in the software w ill meet the
Licensee ’s requirements, b) that the Software wil l operate in the hardware or software combin ations that the Li censee
may select, c) that the operation of the Software will be uninterrupted or error free, or d) that all defects in the
operati on of the Softwar e w ill be corrected. Bay Network s is not obligated to remedy any Software defect that cannot
be repro duced with the latest Software release. These warranties do not apply t o the Software if it has been ( i) altered,
except by Bay Networks or in ac cordance with its instructions; (ii) used in conjunction with another vendor’s product,
resulting in the defect; or (i ii) damaged by impr oper environm ent, abuse, misuse, accident, or negligence. THE
FOREGOING WARRANTIES AND LIMITATIONS ARE EXCLUSIVE REMEDIES AND ARE IN LIEU OF ALL
OTHER WARRANTIES EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Licensee is responsible for the security of
303563-A Rev 00
iii
its own data and informat ion and for maintai ning adequate pro cedures apart from the Software to re construct lost or
altered files, data, or programs.
4. Limitation of liability. IN NO EVENT WILL B AY NETWORKS OR ITS LICENSORS BE LIABLE FOR ANY
COST OF SUBSTITUTE PROCUREMENT; SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES ; OR ANY DAMAGES RESULTI NG FROM INACCURATE OR LOST DATA OR LOSS OF USE OR
PROFITS ARISING OUT OF OR IN CONNECTION WITH THE PERFORMANCE OF THE SOFTWA RE, EVEN
IF BAY NETWORKS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. IN NO EVENT
SHALL THE LIABILITY OF BAY NETWORKS RELATING TO THE SOFTWARE OR THIS AGREEMENT
EXCEED THE PRICE PAID TO BAY NETWORKS FOR THE SOFTWARE LICENSE.
5. Governmen t L icensees. This provision applies to all Sof tware and documentation acquired directly or indirectly
by or on behalf of the United States Government. The Software and documentation are commercial products, licensed
on the open market at market pri ces, and were developed entirely at private expense and without the use of any U.S.
Government funds. The lic ense to the U.S. Gov ernment is granted only with restric ted rights, and use, duplication, or
disclos ure by the U.S. Government is subject to the restrictions set forth in subparagraph (c )(1) of the Commercial
Computer So ftware––Restric ted Rights clause of FAR 52.227-19 and the li mi tations set out in this license for civilian
agencies , and subparagrap h (c)(1)(ii) of the Rights in Technical Data and Compu ter Software clause of DFARS
252.227-7013, for agencies of the Departmen t of Defense or their successors, whi chever is app licable.
6. Use of Software in the European Community. This provision applies to all Software acquired for use within the
European Comm unity. If License e uses the Software within a country in the European Community, the Softw are
Directive enacted by the Council of European Communities Directive dated 14 May, 1991, w ill apply to the
examination of the Softwar e to facilitate interoperability. Licensee agr ees to notify Bay Netw orks of any such
intended examination of the Software and may procure support and assistance from Bay Networks.
7. Term and termination. This license is effective until terminated; however, all of the restrictions with respect to
Bay Networks’ copyright in the Software and user manuals will cease being effective at the date of expiration of the
Bay Networks copyright; those restrictions relating to use and d isclosure of Bay Networks’ confidential informati on
shall continue in effect. Licensee may terminate this license at any time. The license will automatically terminate if
Licensee fail s to comply with any of the terms and conditions of the license. Upon terminat ion for any reaso n ,
Licensee will immediately destroy or return to Bay Networks the Software, user manuals, and all copies. Bay
Networks is not liable to Licensee for damages in an y form solely by reason of the termination of this license.
8. Export and Re-export. Licensee agr ees not to export, directly or indirectly, the Software or related techn ical data
or information without first obtaining any required export licenses or other governmental approvals. Without limiting
the fore going, Licensee, on behalf of itself and its subsidiaries and affiliates, agrees that it will not, without first
obtaining all export licenses and approvals required by the U.S. Government: (i) export, re-export, transfer, or divert
any such Sof tware or technical data, or any dire ct product thereof, to any country to whi ch such exports or re-exports
are rest ricted or embargoed under United States export control laws and regulations, or to any national or resident of
such rest ricted or embar goed countries; or (ii) provide the Software or related technical data or information to any
military end user or for any military end use, including the design, development , or production of any ch em ical,
nuclear, or biological weapons.
9. General. If any provision of this Agreement is held to be invalid or unenforceable by a court of competent
jurisdiction, the remainder of the provisions of this Agreement shall remain in full force and effect. This Agreement
will be governed by the laws of the state of California.
Should you have any questi ons concerning this Agreement, contact Bay Networks, Inc., 4401 Great Americ a
Parkway, P.O. Box 58185, Santa Clara, California 95054-8185.
LICENSEE ACKNOW LEDGES THAT LICENSEE HAS READ THIS AG REEMENT, UNDERSTANDS IT, AND
AGREES TO BE BOUND BY ITS TERMS AND CONDITIONS. LICENSEE FUR THER AGREES THAT THIS
AGREEMENT IS THE ENTIRE AND EXCLUSIVE AGREEMENT BETWEEN BAY NETWORKS AND
LICENSEE, WHICH SUPERSEDES ALL PRIOR ORAL AND WRITTEN AGREEMENTS AND
COMMUNICATIONS BETWEEN THE PARTIES PERTAINING TO THE SUBJECT MATTER OF THIS
AGREEMENT. NO DIFFERENT OR ADDITIONAL TERMS WILL BE ENFORCEABLE AGAINST BAY
NETWORKS UNLESS BAY NETWORKS GIVES ITS EXPRESS WRITTEN CONSENT, INCLUDING AN
EXPRESS WAIVER OF THE TERMS OF THIS AGREEMENT.
iv
303563-A Rev 00
Contents
Preface
Before You Begin ..............................................................................................................xi
Text Con ventions ............................... .................................... ....................... ....................xii
Acronyms .........................................................................................................................x iv
Bay Networks Technical Publications ..............................................................................xiv
How to Get Help ..............................................................................................................xv
Chapter 1
Creating a Script File
About Variables ..............................................................................................................1-2
Local, Global, and System Variables .......................................................................1-4
Special Variables ............................................................................................................1-4
Table 2-4.Special Charac te rs .................................................. ..............................2-31
303563-A Rev 00
ix
This guide describes creating and editing Technician Interface scripts.
Before You Begin
This guide is intended for network administrators with the following background:
•Knowledge of the UNIX operating system and the C programm ing language
•A general under standing of local area and wide area networking fundamentals
•An understanding of the transmi ssion and management protocols used on
your network
Preface
303563-A Rev 00
Before using this guide, you must load the router software from the release
medium. This guide assumes that you are fa miliar with the Technici an Interface.
For information on this interface, refer to Using Technician Interface Software.
xi
Writing Technician Interface Scripts
Text Conventions
This guide uses the following text conventions:
angle brackets (< >)Indicate that you choose the text to enter based on the
description inside the brackets. Do not type the
brackets when entering the command.
Example: If the command syntax is:
bold text
<ip_address>
ping
ping 192.32.10.12
Indicates text tha t you need to enter and command
, you enter:
names and options.
Example: Enter
Example: Use the
show ip {alerts | routes
command.
dinfo
}
braces ({})Indicate required elements in syntax descriptions
where there is more than one option. You must choose
only one of the options. Do not type the braces when
entering the command.
Example: If the command syntax is:
, you must enter either:
show ip {alerts | routes
show ip alerts or show ip routes
}
.
brackets ([ ])Indicate optional elements in syntax descriptions. Do
not type the brackets when entering the command.
Example: If the command syntax is:
, you can enter either:
show ip interfaces [-alerts
show ip interfaces
or
]
show ip interfaces -alerts
.
xii
ellipsis points (. . . )Indicate that you repeat the last element of the
comman d as need ed .
Example: If the command syntax is:
ethernet/2/1
ethernet/2/1
[<
parameter> <value>
and as many parameter-value pairs as
] . . .
, you enter
needed.
303563-A Re v 00
Preface
italic textIndicates file and directory names, new terms, book
titles, and variables in command syntax descriptions.
Where a variable is two or more words, the words are
connected by an underscore.
Example: If the command syntax is:
show at <
valid_route
valid_route>
is one va riable and you subs titu te one value
for it.
screen textIndicates system output , fo r exa mple, prompts and
system messages.
Example:
Set Ba y Netw orks Tr ap Mo nito r Fil ters
separator ( > )Shows menu paths.
Example: Protocol s > IP identifies t he IP option on the
Protocols menu.
|
vertical line (
)Separates choices for command keywords and
arguments. Enter only one of the choices. Do not type
the vertical line when entering the command.
Example: If the command syntax is:
show ip {alerts | rou tes}
show ip alerts
show ip routes
or
, you enter either:
, but not both.
303563-A Rev 00
xiii
Writing Technician Interface Scripts
Acron yms
ANSIAmerican National Standards Institute
ARPAddress Resolutio n Protocol
ASCIIAmerican Stan d ard Co de fo r In formation Interch a n ge
ATMasynchronous transfer mode
FDDIFiber Distributed Data Interface
MACmedia access control
MIBmanagement information base
OSIOpen Systems Interconnec tion
OSPFOpen Shortest Path Fi rst
RIPRouting Information Protocol
SNMPSimple Network Management Protocol
Bay Netwo rks Technical Publications
xiv
You can now print Bay Networks te chnical manuals and release notes free,
directly from the Int ernet. Go to support.bayn etworks.com/libr ary/tpubs/. Fi nd the
Bay Networks product for which you need doc umenta tion. Then locate the
specific category and model or version for your hardware or software product.
Using Adobe Acrobat Reader, you can open the manuals and release notes, sear ch
for the sections you need, and print them on most standard printers. You can
download Acrobat Reader free from the Adobe Systems Web site,
www.adobe.com.
You can purchase Bay Networks document ation sets, CDs, and selected technical
publications through the Bay Networks Collat era l Catalog. The catalog is located
on the World Wide Web at support.baynetworks.com/catalog.html and is divided
into sections arran ged alpha betically:
•The “CD ROMs” section lists available CDs.
•The “Guides/Books” section lists books on technical topics.
•The “Technical Manuals” section lists available printed documentation sets.
303563-A Re v 00
Make a note of the part numbers and prices of the items that you want to order.
Use the “Marketing Collateral Catalog description” link to place an order and to
print the order form.
How to Get Help
For product assista nce, support contracts, or information about educational
services, go to the following URL:
http://www.baynetworks.co m/corporate/contacts/
Or telephone the Bay Networks Technical Solutions Center at:
800-2LANWAN
Preface
303563-A Rev 00
xv
Chapter 1
Creating a Script File
The Technician Interface script facility allows you to r ead and execute Technician
Interface commands from a script file. You create and edit script files on a remote
workstation and transfer the files to the router via TFTP or XMODEM. For
instructions on using TFTP or XMODEM, see Using Technician Interface Software.
We provide several script programs that let you manage the router using
information store d in the manageme nt information base (MIB). You can use the
scripts to display information about protocols and network services and to enable
and disable protocols, circuits, line s, and services. You may also choose to write
your own scripts, using this manual as a guide. Technician Interface scripts are
very similar to UNIX shell sc ri pts.
303563-A Rev 00
This chapter d escri b es how to perfo r m the following tasks, using the Technicia n
Interface script commands:
•Prompting the user for input, using the special variable
<prompt>
$
•Referen ci ng and using MIB information, using the special variable
<object.attribute.instance>
$
, the
mibget
formatting MIB entries using the
•Creating, using, and dele ting variables, using the
enumenv, getenv, instenv, let, setenv, sprintf
•Changing a local variable into a global variable, using the
•Evaluat ing an ari thmetic or logical expression, using the
•Parsing a text string, using the
cutenv
•Controlling the e xecution of the script, using the
commands
return
and
octetfmt
comman d
instenv
commands, and
command
arrayenv, cutenv
, and
unsetenv
let
if, goto, pause, gosub
commands
export
command
comman d
,
, and
1-1
Writing Technician Interface Scripts
•Writing messages to the console, using the
•Recording console message s to a file, using the
•Handling and recovering from errors, using the
•Inserting comments into a scr ipt file, using the pound sign (#)
•Debugging a script file, using the
•Saving or restoring variable s to or from a file , using the
env
•Running a script file with co mmand line arguments, using the
•Documenting a script file with command lines
About Variables
A variable is a location in the computer’s memory for storing a value. A varia ble
name identifies the location. Variable names can consist of up to 15 alphanum eric
characters and the underscore character (_). The first character of a variable name
must be an alphabetical character. The Technician Interface stores the value of a
variable as a string of ASCII characters. The maximum string le ngth is 255
characters.
commands
verbose
echo
and the
record
on error
comman d
printf
command
command
save env
run
commands
source
and
command
1-2
You can assign a value to a variable using one of the set variable commands
arrayenv, cutenv, enumenv, instenv, let, setenv, mibget,
(
or
sprintf
). For
instructions on using these commands, see Chapter 2.
After you have assigned a value to a variable, you can refer to the variable on a
command line withi n the s cript f ile b y e ntering a dollar s ign ($) bef ore the v aria ble
name (for example,
$a
).
When you refer t o a variable, the Technician Interface substitutes the value set for
the variab le itself. If you want to prevent or delay the substitution of the va riable,
enter the backslash c haracter (\) before the $. The backslash character, also called
the escape character, indicates that special characters follow.
In the following sc ript, the value of
setenv a blue
setenv b “My color is \$a”
echo $b
My color is blue
appears on the user’s console.
a
is substituted for
$a
when b is executed.
303563-A Re v 00
Creating a Script File
To prevent a var iable from being expanded, enter two dollar signs ($$) before the
variable name, as sho wn in the following example:
setenv a blue
setenv b “My color is \$a”
echo $$b
My color is $a
appears on the user’s console.
You may embed variables in quote d strings, as shown in the previous example.
The follo wing command line enc loses the va ria ble names
a
and b in braces (
{ }
) to
separate the v aria ble names from other data within the string.
echo “The sum of ${a}+1=${b}”
Note:
If the variable name is followed by a space or an end-of-line character
(carriage retu rn), the b rack ets are optional.
A variable name is usually a literal string of characters preceded by a dollar sign
($). The v ariable name can als o be “b ui lt” dynami cally when the scri pt is e x ecuted
by using a combination of lite ral text and the text stored in other variables.
For example, if you have a va riable named array_10, you can reference this
variable by entering
variable name b y concatena ting the te xt st rings
assign the variable index the value 10, using the command
$array_10
on a command line. You can build this same
array_
and 10. For exampl e, if you
let index = 10
, then
you can bu ild the v ariab le name arr ay _10 dynamic ally on the c ommand line usi ng
the followi ng syntax:
${array_[$index]}
. Notice the use of the brack ets (
[ ]
) within
the variable name. Any literal text or variable name specified within the brackets
is first expanded to replace any variables with their values and then concatenated
onto the preceding characters of the variable name. To use brackets, you must
enclose the entire variable name being built within braces (
{ }
).
303563-A Rev 00
1-3
Writing Technician Interface Scripts
Local, Global, and System Variables
When you first define a variable, the computer stores it in the local environment
variable table. Local variables are only accessible from within the script in which
they were cr eated. Y ou cannot access them from another sc ript file. When a script
routine ends, any local variables that you defined are automatically deleted.
Global variables are stor ed in the global environment variab le table and may be
accessed by any script file. You create global variables by using the
command to change a local variable to a global variable. For more information
about the
export
deleted when a script f ile ends.
System variables, which are read-only, are create d only dur ing a Telnet session.
You cannot have the same variable name in the local and the global variable
tables. You can delete local and global va riab les b y using the
You can also change the value of a global variable by using an y of the set variable
commands (
sprintf
). For more information about these commands, see Chapter 2.
command, see Chapter 2. Globa l variables are not automatic ally
arrayenv, cutenv, enumenv, instenv, let, mibget, setenv
export
unsetenv
command.
, or
The value of a v ariable in the local or g lobal ta ble tak es p recedence ove r
Note:
a variable with the same name in the system variable table.
Special Variables
This section describes how to use input variables, how to prompt for user entry
from the console, and how to acce ss and format information from the MIB.
Input Parameters
The Technician Interface reserves the following variable s as input parameters for a
script file: $1, $2, $3, $4, $5, $6, $7, $8, $9 and $#. The special variab le
contains the number of parameters entered on the command line following the
script file name. It is set to zero if no parameters are entered. For more
information about input parameters, see “
1-4
” in Chapter 2.
run
$#
303563-A Re v 00
Prompting for Input
The input prompt varia ble allows you to create a prompt that accepts user input
from the Technician Interface console. The syntax of the input prompt variable is
<prompt_string>
$
you entered between the bracke ts (< >). In the following script,
setenv ans “$<Enter your name: >”
echo “Your name is $ans”
Creating a Script File
. The Technician Interface pro mpts the user with the message
Enter your name:
T echnician Interface substitutes the value for
name is
followed by the name entered by the user.
For instruct ions on using the
appears on the user’s console. After the user enters a val ue, the
Your
setenv
and displays the message
ans
command and the
command, see
echo
Chapter 2.
Polling the Console for Input
You can spec ify how much time a user has to respond to a prompt (that is, to press
Return) before the system times out. If you do not specif y a timeout value, the
system prompts the user for input until the user responds.
To specify a timeout value, enter the fol lowing command, where
<value_in_seconds>
is the length of ti me, in seconds, th at the s ystem will wa it for
a response before timing out.
let SYS_IO_TIMEOUT = <value_in_second s>
The timeout value cannot exceed the timeout specified by one of the following
MIB object s: wfSerialPort.wfSerialPortTimeOut.0 or wfTelnet.wfTelnetSerialPortTimeOut.0. For example, if you speci fy a timeout of
600 seconds and the timeou t specif ied b y wfSeri alPort.wfSerialPortTimeOut.0 = 5
minutes, the system uses the timeout value given by
wfSerialPort.wfSerialPortTimeOut.0.
303563-A Rev 00
For instruct ions on using the
command, see Ch a pter 2.
let
1-5
Writing Technician Interface Scripts
In the following sc ript, if the user does not press Return before the time specifie d
for SYS_IO_TIMEOUT has elapsed,
console:
let SYS_IO_TIMEOUT = 10
setenv ans “$<Enter your name: >”
echo “Your name is $ans”
if “$ans” = “” then; \
echo “nothing entered”
To change the timeout back to an indefinite waiting period, use the following
command:
unsetenv SYS_IO_TIMEOUT
For more information about using the commands in the prece d ing examp l es, s ee
Chapter 2.
Accessing MIB Information
The Technician Interface scri p t facility al lows you to assign the value of a MIB
attrib ute to a v a riable . Using the synt ax
to the following types of MIB variables:
nothing entered
$
<object.attribute.instance>
appears on the user’s
, you can refer
1-6
•Counter varia bles, which keep track of how many times an ev ent occurs.
•Display string v aria bles, which spe cify a pi ece of inf ormation s tored i n ASCII
characters, and which the syste m can display for the user to read. The string
must be shorter than 255 characters.
•Gauge variable s, which keep track of values that fluctuate.
•Integer v ariables, which specify information in the form of a simple integer.
303563-A Re v 00
Creating a Script File
The variabl e values
<object>
<attribute>
is the name or identifie r of the object (for exampl e, wfSnmp).
is the name or identifie r of the attr ibute (for example,
<object>, <attribute>
, and
<instance>
are defined as follows:
wfSnmpDisable).
<instance>
is the identifie r of a nontabular obje ct or the index value of a tabular
object (for exampl e, 1).
For more information about
<object. attribute. instance>
, see Using Technician
Interface Software.
Using the syntax
$
<object.attribute.instance [index]>
, you can refer to the
following type s of data:
•Opaque string data
•Octet string data
Opaque and octet string data are hexadecimal numbers that start with 0x.
The variable value index is the byte offset into the opaque or octet string data. An
offset of 0 r eturns the lengt h of the data in b yte s. Each b yt e is a ccessed, one b yte a t
a time, using the index number. For example, to acces s the v alue of a byte in an
octet string, use the following procedure:
Enter
1.
$<
object.attribute.instance
$(wfHwBase.wfHwBpRev.0[0])
The system returns the number of bytes in the octet string (for example, 4).
Enter
2.
$<
object.attribute.instance[n
$(wfHwBase.wfHwBpRev.0[3])
example, the third byte).
Formatting a MIB Entry
octetfmt
The
using the specif ied format type. Fo r more info rmation about using the
command, see Chapter 2.
303563-A Rev 00
command formats a MIB entry with an Octet or Opaque data type
(for example,
[0]>
) to get the length of the da ta i n by tes.
(for example,
]>
) to get the value of the sele cte d by te (for
octetfmt
1-7
Writing Technician Interface Scripts
Defining a Pseudo-Variable Array
The Technician Interface scri p t facility al lows you to define a pseudo-variable
array. A true array is a set of consecutiv e memory locations used to store data.
Each item in the array is called an element. An element is a variable. To reference
an element of an array, you use a number called the index. In a pseudo-variable
array, the elements (variables) are not in consecutiv e memory locations. To create
a pseudo-array, use variable names that end in numbers (for example,
). The following script shows how to access a member of an array using an
a3
index:
setenv a1 one
setenv a2 two
setenv a3 three
let index=2
echo “a[$index]=${a[$index]}”
a1, a2
, and
a[2]=two
is displayed on the user’s console.
For specific instructions on using the commands in the previous example, see
Chapter 2.
Creating and Using Variables
This section explains how to view local and global variables, how to set variables,
and how to delete them.
Viewing Variables
You view the current list of variables stored in the local and global environment
variable tables using the
getenv a
the system responds
You can also use the
For specific instructions on using the
getenv
a = blue
echo $
<variable_name>
command. For example, if you enter
.
command to view a variabl e.
getenv
and
commands, see Chapter 2.
echo
1-8
303563-A Re v 00
If you access the Technician Inter fa ce via Telnet, the Technician Interface also
displays the v ariables in the system environment v ariable table. Variables in this
table are read-only from the Technician Interface. If your Telnet client supports
the environment variable option, you can use Telnet to send your UNIX
envir onment variables to the T echnician Interface’s system list. See your Telnet
client documentati on for instructions.
Note:
table, have the same name, the one in the local or global table is used.
Setting Variables
The Technician Interface provides several ways to set variables, depending on
what you want to accomplish in y our script. Th is sec tion lists the ways you can set
variable s. For details on each of the following commands, see Chapter 2.
•To assign an ASCII string or numeric value to a variable in the local
environment variable table, use the
Creating a Script File
If two vari ables, one in the system table and one in the local or global
setenv
command.
303563-A Rev 00
When you assign a value to a variable, you do not type the
before the
$
variable. If the value contains spaces or tabs, place double quotes (“”) around
the value string. In the following command, you assign the value
to the variabl e a.
Menu
setenv a “Statistics Menu”
Statistics
•To define a pseudo-var iable array that contains the list of MIB instance IDs
for a give n MIB object name, use the
The
instenv
command builds a pseudo-variable array by appending an index
instenv
command.
number to the v ariable name specified on the command line. Each member of
the pseudo-va riable array contains a single instance ID. The size of the
pseudo-array is store d at ind ex 0.
We recommend that you use the
Note:
instenv
command. The
mibget
50 percent faster than the
mibget
command accesses MIB tables appr oximately
instenv
comman d.
command instead of the
•To select parts of a text string and write them to a pseudo-variable array, use
the
cutenv
comman d.
1-9
Writing Technician Interface Scripts
•To convert and for mat text, and save the result in a specified variable for later
use, use the
sprintf
•T o e v al uate a simpl e arithmeti cal or logical expr ession and assi gn the result to
a given var i a b l e , use th e
command evaluates an expre ssion from left to right (def ault). You can
let
The
use parentheses to change the order of the evaluation.
•To write a list of command line arguments into a pseudo-variable array , use
the
arrayenv
command.
You can append arg uments to the end of an existing vari able array with the
option. If an argu ment conta ins spaces, place double quote s (“”) around it ( for
example,
“enclose this one”
command.
let
command.
).
-a
•To assign a sequence of values to a list of variable names, use the
command. You must indicate a starting number and, optionally, you can
specify a value by which to incr ement the v al ues in the series . You can use the
sequence you have created as named indices of an array variable. Primari ly,
you use this command with the
created by that command.
Deleting Variables
To delete one or more variables from the local or global environment variable
table, use the
unsetenv a
the system deletes v ariable a from the table.
You cannot delete a variable from the system environment variable table.
You can delete all var iables that are part of a pseudo-variable array by using the
wildcard character *. For example, to delete all variable s that begin with
enter the following command:
unsetenv array_*
unsetenv
arrayenv
command to index the value s
command. For example, if you enter
enumenv
array_
,
1-10
For specific instructions on using the
unsetenv
command, see Chapter 2.
303563-A Re v 00
Setting the Current Volume or Directory
When you set the current working v olume or directory using the cd (change
directory) command, you are set ting the global variable “PWD” to the value you
specify in the command, as sho wn in the following script:
cd 3:
echo $PWD
3:
getenv PWD
PWD = “3:”
Controlling Program Flow
The Technician Interface provides several commands to control program flow in
your script. For details on each of the following commands, see Chapter 2.
Creating a Script File
•To specify the next line to be exec ute d from the script file, use the
goto
command.
With in the script file, use the
command with a label. A label begins and
goto
ends with a colon (:), consists of up to 15 alphanu meric characters and the
underscore character (_), and must be on its own line, beginning in column 1.
•T o evaluate whether an e xpressio n is t rue, use th e
command. The express ion
if
can compare two numerical v a lues or two ASCII strings. If the expression is
true, the script interpreter executes any additi onal commands that are on the
same command line as the
command. If the expression is false, the script
if
interpreter does not execute the if command.
You use a semicolon (;) to e nd an
command. The semicolon separates the if
if
command from the commands you want ex ecute d if the if command is true.
•To suspend the Tec hnician Interface’s operation for a given interval, use the
command. During this time the router is still running.
pause
•To call a subroutine inside the same script file, use the
gosub
command. It
must be the last command on a line. You can nest subroutines up to 10 deep.
You use the
When the
return
the instructions on the line following the line containing the
command in a subroutine to return to the calling routine.
return
command executes, the script interpreter begins executing
gosub
command.
303563-A Rev 00
1-11
Writing Technician Interface Scripts
Writing Messa ge s to the Cons o le
The Technician Interface provides two commands to display messages on the
console:
•Use the
command to display command line arguments to the user’s
echo
terminal.
•Use the
command to convert, format, and print input arguments on the
printf
T echnician Interface’s console.
For details on each of these commands, see Chapter 2.
Saving Console Messages to a File
To save to a file all messages that are written to the console terminal, use the
record
command.
The record fi le must be opened before re cording, and the fi le must be cl osed when
recording is completed. The file will be lost if it is not closed before the file
system is unmounted or the router is reset.
For specific instructions on using the
record
Perf orming Error Recovery
T o spe cify an error handler la bel withi n a script f ile , use the
a command returns an error or if you attempt to abort the scr ipt file, the script
interpreter goes to the error handler label defined in the file. If you press Ctrl-c to
abort the script, the Technician Interface displays the following prompt:
command, see Cha p te r 2.
on error
command. If
1-12
Terminate script file? (y/n):
You can use the
on error
without returning an error messa ge if the
command with the -s flag to allow the scr ipt to rec over
on error
command cannot locate a
specifie d script f ile . The follo wi ng e xample sh o ws t he
flag:
-s
on error -s :ERROR_HANDLER:
For more information about the
on error
command, see Chapter 2 in this manual.
on error
command with the
303563-A Re v 00
Inserting Comments
You can insert comments into the script file. Comments begin with a pound sign
(#) in column 1, as shown in the following example:
# The 'echo' command is used to
# output messages to the user’s console.
When you execute a script file, the system does not display the comments on the
user’s console.
Debugging a Script File
Creating a Script File
To enable the debug trace facility, use the
the trace facility, the Technician Interface displays each command read from the
script file before and after its variables have been expanded. For instructions on
using the
verbose
command, see Chapter 2.
Saving and Restoring Variables
To save the current list of local and global variables to a file, use the
command. For example, to save the variables to a file named test, enter the
following c ommand:
save env test
To read and execute the commands in a Technician Interface script file, and to
ensure that the router saves (restores) all local variables when the script ends, use
the
source env
For example, to run the script file test on volume 2, and to restore upon
completion all local va riables saved previously to test, enter the following
command:
source env 2:test
T o lo cate script errors, use the
command. The Technician Interface displays each line from the file before it
executes the line, enabling you to easily locate errors.
command.
verbose on
verbose
command. When you enable
command and then use the
save env
source env
303563-A Rev 00
For more information about the
Chapter 2.
sa ve env
and
source env
commands, see
1-13
Writing Technician Interface Scripts
Running a Script File
To read and execute the commands in a Technician Interface script file, and to
ensure that the router deletes all local variables when the script ends, use the
command.
For example, to run the script file test on volume 2, deleting upon script
completion all local va riables saved previously to test, enter the following
command:
run 2:test
run
To locate script errors, use the
command. The Technician Interface displays each line from the file before it
executes the line, enabling you to locate errors easily.
You can use the
returning an error message if the
file. The following example shows the
run -s install.ba
The
Note:
the script file name you specify. If you issue the command
system fir st looks for a file named install. If it cannot find this file, it looks for
a file named instal l.bat.
For more information about the
Creating Menus
The menu utility allows you to edit existing script menus and to create your own
menus. For instructions on using the menu utility, refer to Using Te chnician Interface Scripts.
verbose on
command with the -s flag to prevent the system from
run
run
t
command automatically appends the .bat suffix to the end of
run
command, see Ch ap ter 2.
run
command and then use the
command cannot locate the specified script
command with the -s flag:
run
run install
run
, the
1-14
You can also edit a script menu by directly editing the appropriate .mnu file.
Appendix A shows exam ples of a script menu and a script.
303563-A Re v 00
Chapter 2
Command Reference
In the following pages you can find the function, syntax, and examples of all the
script commands you need to write, edit, and execute your script files. Table 2-1
lists the script commands and their fu nctions.
Table 2-1.Script Commands
CommandFunction
303563-A Rev 00
arrayenv
cutenv
echo
enumenv
export
getenv
gosub
goto
if
instenv
let
mibget
octetfmt
Writes list of command line arguments to a pseudo-variable array
Selects part of a text string and writes it to a pseudo-variable array
Displays command line argum ents to a user’s terminal
Assigns a sequence of values to a list of variables
Moves one or more local variables to the global environment variable
table
Displays t he current list of variabl es stored in the local and global
environment variable tables
Calls a subroutine ins ide the same script file
Specifies the ne xt line to be execute d fro m the script file
Evaluates whether an expression is true
Defines a pseudo-variable array that contains the list of MIB instance
IDs for a giv en M IB obj ect name
Evaluates a si mp le arithmetical or logical expression and assigns the
result to a given variable
Searches a MIB object table one record at a ti m e and retrieves a set of
attributes from each record
Formats a MIB entry with an Octet or Opaque data type
(continued)
2-1
Writing Technician Interface Scripts
Table 2-1.Script Commands
CommandFunction
on error
pause
printf
record
return
run
save env
setenv
source env
sprintf
unseten v
verbose
Specifies an error handler label within a script file
Suspends the Technicia n Interface’s operation for a given interval
Converts, formats, and prints the input arguments on t he Technician
Interface’s console
Saves to a file all messages written to the console terminal
Returns control to the calling routine
Reads and ex ecute s the Technician Interface com mands in a scri pt fi le;
deletes local variables when the script ends
Saves the current list of local and global variables to a script file
Assigns an ASCII string v alue or a numeri c val ue to a v ariab le in a local
environment variable table
Reads and ex ecute s the Technician Interface com mands in a scri pt fi le;
saves (restores) local variab les when the script ends
Converts and formats text, and saves the result in a specified variable
Deletes one or more variables from the local or global environment
varia ble table
Enables the debug trace facility
(continued)
2-2
303563-A Re v 00
arrayenv
Command Reference
The
arrayenv
<text_string>
<variable_name>
variable array using the
command allows you to write a list of command line arguments
to a pseudo-variable array, beginning with the prefix
. You can also append arguments to the end of an existing
option.
-a
Syntax
The
arrayenv
arrayenv [-a
appends the new arguments to the end of a variable array.
-a
<variable_name>
<text_string>
command has the following syntax:
] <
variable_name
>
<text_string>
“
<text_string>
” [“
. . .
”
]
is the name of the variable that holds the array.
contains the command line arguments. If the text for the arguments
contains blanks or speci al characters, enclose it in double quotes (as shown in
syntax). For example, to pass the argument Router One, specify
“Router One”
the statement.
Example
The following examp le se ts u p an arra y named
attribute
, specifie s a series of
values for the array, appends a value to the list, and then prints the number of
elements in the array, the value of the f irst element and the value of the last
element. The size of the pseudo-variable array is stored at index 0.
in
303563-A Rev 00
arrayenv attribute one two “three & four” five “six & seven”
arrayenv -a attribute “Router One”
echo “Size: ${attribute[0]}”;
echo “First element: ${attribute[1]}”;
echo “Last element: ${attribute[${attribute[0]}]}”;
The output from this script is as fol lows:
Size: 6
First element: one
Last element: Router One
2-3
Writing Technician Interface Scripts
cuten v
The
cutenv
specified by
prefix
command allows you to select portions of a
) and write them to a pseudo-va riable array, beginning with the
<list>
<variable_name>
. The items specified by
<text_string>
can represent column
<list>
(as
position or fi elds delimited by a speci al character. Column and field numbering
start at 1.
Syntax
The
cutenv
cutenv [-s] [-d
<text_string>
“
suppresses
-s
<delimiter>
-d
command has the following syntax:
<delimiter>
”
<text_string>
sets the field delim iter to
] [
-f
<list>
| -c
<list>
with no delimiter characters.
<delimiter>
]
<variable_name>
. The default is a tab.
Character s with a spe cial meaning to the Technician Interface interpreter, such as
a tab or space character, must be set in quotes.
-f
is field positi on. I nstead of character positions,
<list>
specifies fields that
<list>
are separated by a delimiter (for example, a tab). Separate variables are created for
each noncontiguous field of characters selected. For e xample :
1,4,7 represent fields 1, 4, and 7.
2-4
-c
is character position.
<list>
is a comma-separated list of integer field
<list>
numbers (in increasin g order ), with an optional hyphen (-) to indicate ranges.
Separate var iables are created for each noncontiguous set of characters. For
example:
2,4,6 repres ent cha racters 2, 4, and 6.
1-5,9 represent characters 1 through 5, inclusive, and 9.
-5,10 represent the first character in the list through 5, inclusive, and 10.
5- represent the character 5 through the last character in the list, inclusive.
Numbers and number range s may be repeated, overlapping, and in any order . You
can select fields or columns not present in the text string.
<variable_name>
is the prefix or name representing the pseudo-variable array.
303563-A Re v 00
Command Reference
<text_string>
with no field delimiter s is normally passed through in its entirety.
Example
The following sample script shows how you use the
portions of 192.32.100.55 to a pseudo-variable array:
command allows you to display its command line arguments to the
echo
user’s terminal.
Syntax
The
echo
command has the following syntax:
echo
<text_string>
or
echo $
<text_string>
<variable_name>
<variable_name>
is any literal text.
is the name of a variable.
Example
For example, when you execute the script
echo Good Morning
the system displays
Good Morning
on the user’ s console.
When you execute the script
setenv b blue
echo $b
2-6
the system displays
blue
on the user’s console.
303563-A Re v 00
enumenv
Command Reference
The
enumenv
You assign a starting number
which to increment the enumeration <
command with the
command lets you assign a sequenc e of va lues to a list of v ar iables.
and can optionally specify a value by
increment
+
>. Most commonly, you use thi s
arrayenv
<starting_#>
command to create na med indic es to us e with a va lue
array. That way you can refer to the elements of the array with meaningf ul na me s
rather than inde x numbers. For an example, see the
mibget
comman d.
Syntax
The
enumenv
enumenv
<starting_#>
+<increment>
<variable_name>
command has the following syntax:
<starting_#>
<increment>] <variable_name> [<variable_name>
[+
is the starting number of the enumeration.
is the value by which to increment the enumeration.
is the pseudo-variable array.
. . .]
Example
The follo wing example creates indices for attributes in a value array. In t he re sult,
1 is the starting number and the v alues increment by 1. Therefore, the variable
named
enumenv 1 proto dest next hop mask metric as
is 1, the variable named
proto
is 2, and so on.
dest
303563-A Rev 00
2-7
Writing Technician Interface Scripts
export
The
export
command allows you to mov e one or more local variables to the
global environment varia ble table. (When you first define a variable, it is stor ed in
the local en vironme nt v ariabl e table.) Globa l va riabl es can be accessed fr om other
script files. You cannot move global variables to the local environment variable
table.
Syntax
The
export
export
command has the following syntax:
<variable_name>
or
export
<variable_name> <variable_name>
. . .
Example
For example:
setenv A “string”
let B = 1
export A B
2-8
303563-A Re v 00
getenv
Command Reference
The
getenv
command allows you to view t he current list of variables stored in the
local and global environment variable tables. I f you acce ss the Technician
Interface via Telnet, the Technician Interface also displays the variables in the
system environment variable table. Variables in this table are read-only from the
T echnician Interface. If your Telnet client supports the environment variable
option, you can use Telnet to send your UNIX environment variables to the
T echnician Interface’s system list. See your Telnet client documentation for
instructions .
Syntax
The
getenv
getenv
<variable_name>
To display the current list of variables in all tables, enter the
command has the following syntax:
<variable_name>
is the name of the variable whose value you want to display.
getenv
comman d
with no arguments.
If two variables, one in the system table and one in the local t abl e, have
Note:
the same name, the one in the local table is displayed.
303563-A Rev 00
2-9
Writing Technician Interface Scripts
gosub
The
command calls a subroutine inside the same script file. It must be the
gosub
last command on a line. A subroutine begins and ends with a colon (:). You can
nest subroutines up to 10 deep. You use the
return to the calling routine. When the
return
command in a subroutine to
return
command executes, the script
interpreter begins executing the instructions on the line following the line
containing the
command lets you specify the next line to be executed from the script
goto
command is used with a label. A label begins
goto
and ends with a colon (:), consists of up to 15 alphanumeric characters and the
underscore character (_), and must be on its own line, beginning in column 1.
Syntax
The
goto :
<label_name>
command has the following synta x:
goto
<label_name>
:
is the name of the label.
Examples
In the following sc ript, you instruct the script file to go to the :LABEL: label.
The follo wing examples only work from a script file ; the examples will
Note:
not work from an inte ract ive Technician Interface console.
goto :LABEL:
echo “This line is not executed.”
:LABEL:
303563-A Rev 00
The argument to the
command can be a v ariable whose value is a valid label
goto
in the script fi le. This allows for dynamic branching within the script f ile.
setenv vector “:LABEL_2:”
goto $vector
echo “This line is skipped.”
:LABEL_2:
2-11
Writing Technician Interface Scripts
if
The
command allows you to evaluate whether an expression is true. The
if
expression can be a comparison of two numerical values or two ASCII strings. If
the expre ssion is tr ue, t he scri pt inte rprete r e xe cutes a n y addit ional c ommands t hat
are on the same command line as the
script interpre ter does not execute the if command.
command. If the expression is f alse, the
if
You use a semicolon (;) to end an
command. The semicolon separates the if
if
command from the additional commands you want e xecuted if the if command is
true.
Syntax
The if command has the following synta x:
[
<option>] <string1> <operand> <string2>
if
then;
<command>
[
<command>
;
...]
<option>
-u
-num
-ip
-ipx
-ic
-file
is one of the following ar guments:
tests whether
tests whether
tests whether
tests whether
<string1>
<string1>
<string1>
is an unsigned number.
<string1>
is a number .
is an IP address.
is an IPX address.
means ignore case when comparing strings.
tests whether
<filename>
is present.
2-12
tests whether
-dir
tests whether
-vines
tests whether
-date
tests whether
-time
tests whether
-tz
<directory_name>
<string1>
<string1>
<string1>
<string1>
is a VINES address.
uses the date format MM/DD/YY.
uses the time format HH:MM:SS.
uses the GMT offset format [+ | -]HH:MM.
is present.
303563-A Re v 00
Command Reference
<string1> <string2>
<operand>
is one of the following compar ison operations:
are ASCII character strings or numbers.
(=) equal (!=) not equal
(>) greater than (>=) greater than or equal
(<) le ss tha n (<=) less than or e q u a l
then
is an optional word used for ease of reading.
<command>
If both
command is a numeric comparison. If
is a Tech nic ia n Interface command .
<string1>
and
<string2>
are numbers, the test express ion for the if
<string1>
and
<string2>
are not numbers, a
case-sensitive string comparison is done. You specify a case-insensitive
comparison using the
The syntax for certain data types may also be teste d using the
-ipx
or
argument. If the test on
If the test on
<string1>
-ic
argument.
<string1>
is valid, a 1 is substituted for
is inv alid, a 0 is substituted for
-u, -num, -ip
<string1>
.
Example 1
,
<string1>
.
303563-A Rev 00
The followin g example shows a script using the if command. The comments
explain what is happening in the script.
setenv A “YES”
setenv B 1993
#string comparison
if “$A” = “YES” then ; echo TRUE ; date
#numeric comparison
if “$B” != “2001” then ; echo FALSE ; date
#test for valid IP address syntax
if -ip 192.88.22.33 = 1 then ; echo TRUE
#case-insensitive string comparison
if -ic “ABC” = “abc” then ; echo TRUE
#test for valid date, time, and timezone offset syntax
if -date “10/10/94” = 1 then; echo “Good”
if -time “10:10:44” = 1 then; echo “Good”
if -tz “-5.00” = 1 then; echo “Good”
2-13
Writing Technician Interface Scripts
The backslash character (\) allows you to continue a command line on the
following physical line. When used in this way , the backslash is referred to as a
line continuation character. The line continuation character makes it easier for
you to read the script file. The maximum command line size is still restricted to
255 characters.
Example 2
The following example shows an if command using the backslash character:
if $num = 1 then ; \
echo “The number is 1”;
We recommend that you indent the additional commands to make the script file
easier to read. Also, if the re is a lar ge amount of code following the
use a
goto
command to branch around the conditional code.
Example 3
command,
if
The following example shows an if command with a
if $num !=1 then ; goto :IF_10:
echo “the number is 1”;
:IF_10:
goto
comman d:
Example 4
The following script shows how the if command is used to pass parameters into
the script fi le.
echo “Number of parameters entered on run line: $#”
let index = 1
:LOOP:
if $index > $# then; goto :LOOP_END:
echo “Parameter $index: ${[$index]}”
let index = $index + 1
goto :LOOP:
:LOOP_END:
To test whether a variable is defined, use the if command with the following
syntax:
if $?
<variable_name>
=1
where 1=define d.
2-14
303563-A Re v 00
Command Reference
Example 5
For example, the following script tests whether variable a has been defined:
setenv a 5
if $?a=1 then; \
echo “Defined”
To test whether a file is present, use the if command with the following synt ax:
if -file
<filename>
=1
Example 6
For example, the following script tests whether the install.bat file is present:
if -file install.bat=1 then;\
echo “File present”
To test whether a directory is present, use the if command with the following
syntax:
if -dir
<directory _name>
=1
Example 7
For example, the following script tests whether volume 2 is present:
if -dir 2:=1 then;\
echo “Volume 2 present”
303563-A Rev 00
2-15
Writing Technician Interface Scripts
instenv
The
instenv
the list of MIB instance IDs for a given MIB object name. The
command allows you to define a pseudo-variable array that contains
instenv
command
builds a p seudo-variable array by appending an index number to the v a riable name
specified on the command line. Each member of the pseudo-variable array
contains a single instance ID. The size of the pseudo-array is stored at index 0.
Syntax
The
instenv
instenv
<array_name>
<object>
command has the following syntax:
<array_name> <object>
is the name you assign the pseudo-variable array.
is the name of the MIB object table from which to retrieve the
information.
We recommend that you use the new
Note:
instenv
50 percent faster than the
command. The
mibget
instenv
mibget
command accesses MIB tables appr oximately
comman d.
command instead of the
Example 1
The first four line s in the following example show how you list the instance IDs
for wfIpInterfaceEntry to the console; the last nine lines show how you use the
1’s complement~Bit negation operator that provides the
bitwise complement of an integer
AND&Arithmetic AND
Incl us ive -OR|Ar ithme ti c in clusive O R
Exclusive-OR^Arithmetic exclusive OR
Logical shift lef t<<Bit-shift to th e lef t, far-right bit set to zero
Logical shift righ t>>Bit-shift to the right, far-left bit set to zero
303563-A Rev 00
2-19
Writing Technician Interface Scripts
let
The
•strlen( )
•strindex( )
•strri nd ex( )
•strpbrk( )
•strmatch( )
•<single_character>
command provides the fol lowing string functions:
The arguments for each function can be a literal character string, a set of
characters enclo sed in doubl e quote s (“”), or the name of an environment variable.
When you specify an en vir onment variable, do not precede the name with $.
If a function returns an offset within a string, an index of 1 refers to the first
character position.
The function
strlen(
The function
function
functions return the offset within
<
substring
strindex(
strrindex(
The function
of the characters given in the character string
offset to the first matching character’s position in
appears in
<set>
strpbrk
The function
<string>
may use wildcards (* or ?) in
strlen( )
<string>
strindex( )
strrindex( )
returns the num ber o f ch ara ct ers in the p ara meter
)
finds t he first occurrence of a s tring i n anoth er s tring. The
finds the last occurrence of a string in another string. Both
<string>
of
<substring>
’s position, or 0 if
<string>
> is not found.
<string>, <substring>
<string>, <substring>
strp b rk( )
(
<string>, <set>
strmatch(
searches
<string>
)
<string>, <pattern>
)
)
<string>
for the first characte r that mat ch e s any
. The function returns the
<set>
<string>
, or 0 if no character of
.
)
compares
<string>
to
<pattern>
. If
matches the pattern, the functi on returns a 1; othe rwise it returns a 0. You
<pattern>
. A * matches any charact er (or no
character), and a ? matches any charac ter in tha t posi tion in the string . A character
must exist in that position for ? to match.
.
2-20
strmatch(
<string>, <pattern>
)
303563-A Re v 00
Command Reference
You can also get the ASCII code for a given character (indicated as one character
within single quotes, such as ‘c’).
let
The
•date( )
•time( )
•timezone( )
command also provides the following date and time functions:
The function
you enter a date string in the format MM/DD/YY (for example,
date( )
used with no argum ents ret urns the curr ent da te in sec onds. If
date(“10/7/95”)
),
the function return s the number of sec onds from January 1, 1900 to that date.
Dates may range from 1/1/00 (Ja nuary 1, 1900) to 12/31/99 ( December 31, 1999) .
If you omit the year, the function uses the current year.
The function
time( )
used with no arguments returns the current local time in
seconds. If you enter a time string in the format HH:MM:SS (for example,
time(“7:04:32”)
), HH:MM , or MM, the function returns the number of seconds
from 12:00 midnight to that time. HH must be a value between 0 and 23,
inclusive. MM must be a value between 0 and 59, inclusive. SS must be a value
between 0 and 59, inclusive.
The function
timezone( )
used with no arguments returns the curr ent time zone in
seconds. If you enter a time-zone string in the format [+|-]HH:MM (for examp l e,
timezone(“-08:00”)
), the function returns the number of seconds for that time
zone from the International Date Line. You enter the time-zone string relative to
GMT, which is 43200 seconds offset from the Internat ional Date Line. The string
must begin with either a plus (+) or a minus (-) sign followed immediately by
HH:MM. HH must be a value between 0 and 11, inclusiv e, and MM must be a
value between 0 and 59, incl usive.
Note:
In the previo us examples, the date variables MM, DD, and YY represent
the numeric val ues of month, day, and year, respective ly. The ti me variables
HH, MM, and SS represent the numeric values of hours, minute s, and seconds,
respectively.
let b = 5 * (10**2);
let capA = 'A'
set env letter “A”
let capA = '$letter'
let len = strlen(“abcdef”)
setenv string “answer=1”
let len = strlen(string)
let index = strindex(string, “wer”)
let index = strpbrk(string, “=:;”)
if $index = 0 then; echo “Missing Delimiter”
let index = strmatch(string, “pat”)
if $index = 0 then; echo “No match found”
let
command are shown below:
303563-A Re v 00
mibget
Command Reference
The
mibget
command lets you search a MIB object table one record at a time and
retrieve a set of attributes from each record. For example, you can use this
command in a script to retrieve information from a routing table and print the
information immediat el y on the console. When you are searching a larger MIB
table, this method is faster and more efficient than using the
instenv
command.
Syntax
The
mibget
mibget [-n
<value_variable_array> <next_instance_variable>
retrieves the information from the next record in the MIB table. You can use it
in a loop to read the next instance following the identity of the instance
<instance_id>
is 192.32.0.2. If you enter the -n option with the c urrent ID, the
just read. For example, the current I D is 192.32.0.1 and the next ID
mibget
command
returns information f or the instance ID 192.32.0. 2.
<pattern>
-p
instance IDs that match the patter n. For example,
specifies an instance ID pattern string. The script returns only
-p 192.32.
* returns all instances
whose address starts with 192.32., such as 192.32.0.0, 192.32.1.1, and so on.
<object>
is the name of the MIB object table from which to retrieve the
information (for examp le, wfIPForwardEntry).
303563-A Rev 00
<attribute_variable_array>
of attributes to be retr ieved. To create this array variable, you use the
is an environmental array variable that contains the list
arrayenv
command. Do not type $ before this variable name, since the input is passed by
reference, not by value. If the attribute is an OCTET string, you can use an
optional format specifier (/<
format specifier, see the
string, the
<instance_id>
mibget
is the first instance to referenc e in the MIB table. You can use the *
octetfmt
command ignores the format specifier.
>) for each array entry. For information on this
format
command. If the attribute is not an OCTET
wildcard. If you use the -n option, this option identifies the instance ID most
recently retri eved .
2-23
Writing Technician Interface Scripts
<value_variable_array>
is the name of an environmental array variable that stores
the values retrieved. The values are in the same order as listed in the attribute
array
<attribute_variable_array>
. Do not type $ before this variable name, since
the input is passed by reference, not by value.
<next_instance_variable>
is the name of the variable that store s the instanc e ID of
the record currently read. If the routine reaches the end of the table, it sets this
variable to the string “END.” In this case, the
mibget
command has not read any
record informatio n. Do not type $ before this variable name, since the input is
passed by reference, not by value.
Examples
The followi ng example sear ches through the IP routing table to retrie v e a series of
attrib utes and prints the result on the Technician Interface console. The object
from which to retrieve information is wfIpForwardEntry. The script uses the
arrayenv
comman d to creat e the attri bute array variab l e
attrib utes from which to retrieve values. Then it uses the
establish meaningf ul names for the indices for
The script reads the first record with the
In the loop (:IP_RT_LOOP:),
nextid
is the
attr
nextflag
turned off.
<instance_id>
name of the value array where the script places the values it retrieves.
.
attr
that lists the
enumenv
option.
command to
value
is the
nextflag
is
set to -n to read through the records. The script print s the values as it retrieves
them and loops again until it ha s retrie v ed the desir ed attri b utes from the entir e set
of records.
2-24
The followi ng examples show how to retrieve attribute va lues from the IP routing
table using the
mibget
command. The comments (#) explai n what is happening in
the script.
# Purpose: Retrieve attribute values from the IP routing table.
command formats a MIB entry with an Octet or Opaque data type
using the specified format type.
Syntax
The
octetfmt
octetfmt
<variable_name>
<format_type>
ASCII_STRING
command has the following syntax:
<variable_name> <form at_type> <MIB_object>
is the name of the variable.
is one of the following values:
returns the data as a printabl e disp lay string. Any data tha t is not
printable is retur ned as its hex value in the form
DEC_BYTES
formats the data as an unsigned decimal number, with each byte
separated by a dot.
DEC_WORDS
formats the data as an unsigned decimal number, with a dot
separating every 2 bytes.
DEC_LONGS
formats the data as an unsigned decimal number, with a dot
separating every 4 bytes.
<00>
.
2-26
HEX_BYTES
formats the data as a hexadecimal string, with each byte separated
by a dot.
HEX_WORDS
formats the data as a hexadecimal string, with a dot separating
eve ry 2 bytes.
HEX_LONGS
formats the data as a hexadecimal string, with a dot separating
eve ry 4 bytes.
HEX_USTRING
or
HEX_STRING
uppercase digits for ‘A-F.’
HEX_LSTRING
formats the data as a hexadecimal string, using lowercase digits
for ‘a-f.’
MAC1_ADDRESS
or
MAC_ADDRESS
address.
formats the data as a hexadecimal string using
formats the data as a canonical MAC
303563-A Re v 00
Command Reference
MAC2_ADDRESS
SIGNED_INTEGER
UNSIGNED_INTEGER
<MIB_object>
formats the data as a noncanonical MAC address.
INTEGER
or
formats the data as a 4-byte signed integer.
formats the data as a 4-byte unsigned integer.
represents the v ariable values
<object.attribute.instance>
.
Example
The followin g example shows a script using the
octetfmt
command. The
command formats the MIB object as a hexadecimal string using uppercase digits.
octetfmt serialno HEX_USTRING wfHwBase.wfHwBpSerialNumber.0
echo \“Backplane serial number: 0x$serialno\”
303563-A Rev 00
2-27
Writing Technician Interface Scripts
on error
The
on error
command allows you to spec ify a n error ha ndler label with in a script
file. If a command returns an error or if the user attempts to abort the script file,
the script interprete r goes to the error handle r label def ined in the file. I f you press
Ctrl-c to abort the script, the Technician Interface displays the following prompt:
Terminate script file? (y/n):
Syntax
The
on error
on error [-s] :
allows the scrip t to reco ver without returning an error message if the
-s
command has the following syntax:
<label>
:
on error
command cannot locate a specified file.
<label>
is the name of the error handler label.
Example
In the following sc ript, the script interpreter goes to the label
:ERROR_HANDLER: when an error occurs:
on error :ERROR_HANDLER:
echo “what
echo “this line is skipped due to the above”
echo “syntax error. (Missing quote)”
:ERROR_HANDLER:
echo “The error handler is called because of the”
echo “deliberate syntax error in the previous command.”
2-28
The error handler is automatic a lly canceled after an error is found or if you issue
the
on error
command without a label.
303563-A Re v 00
pause
Command Reference
The
command allows you to suspend operation of the Te c hnician Interface
pause
for a give n interval. During this time the router is still running.
Syntax
The
pause
<no._of_seconds>
command has the following synta x:
pause
<no._of_seconds>
is the length of the pause in the operation of the Technician
Interface.
Example
The following command suspends operation of the Technician Interface for 10
seconds:
pause 10
303563-A Rev 00
2-29
Writing Technician Interface Scripts
printf
The
(
<p1> ,. . .,<pN>
<format>
command conve rts, formats, and prints the input arguments
printf
) on the Technician Interface con sol e un de r the control of
.
Syntax
The
printf
<format>
<p1> <p2>...<pN>
<format>
inside the
When the
the value of the ne xt input argument that follows the <
command has the following synta x:
printf
<for ma t> <p1> <p2 > . . . < p N >
is the string describing what to print.
represent input argum ents.
contains text to be printed and conversion specifications. Everythi ng
<format>
printf
string is printed, except for the conversion specifications.
command locates a con v er sion specif ic ation, it forma ts and prints
> string. You must
format
have the same number of input ar guments as con vers ion specific ations. The synta x
rules for
The
<format>
command does not automatically outpu t a newline at the end of each
printf
line. You must explicitly output a newline as part of either the
in the argument strings. This feature lets you use multiple
output a single line or you can use a single
are described later in this section.
command to output multiple
printf
<format>
commands to
printf
string or
lines. The special character \n represents a new line.
2-30
Table 2-4
arguments.
lists the special characte rs you can use in the format and input
303563-A Re v 00
Command Reference
Table 2-4.Special Characters
CharacterMeaning
\aaudible bell
\bbackspace
\fform feed
\nnewline
\rc a rr iage return
\ttab
\xhhhex. code
\000octal code
A summary of the flags and con ve rsion codes follows:
) left-justifies data; default is right-justified.
+
) prints a number.
•space ( ) prints a minus sign in fr ont of a neg ative number, or prints a space in
front of a positive number.
0
•zero (
•pound sign (
x
<width>
specifie d as an asterisk (*), then use the next argument as
period (.) separates
<precision>
string, or the minimum number of digits for an integer. If
asterisk (*), then use the next argument as
) pads numeric conversions with zeros.
#
) specifies a n alternate output form if the con version specifier is
or o.
is a number that specifi es the minimum field width. If
<width>
and
<precision>
.
<width>
<width>
specifies the maximum number of characters to be printed from a
<precision>
<precision>
.
is
.
is an
303563-A Rev 00
2-31
Writing Technician Interface Scripts
<conversion_specification>
d or i
•
•
•
•
•
•
•A percent sign (
If you enter the
indicates signed decimal notation.
o
indicates unsigned octal notation (no leading zero).
x
or X indicates unsigned hexa decimal notation (no 0x prefix).
u
indicates unsigned decimal.
c
indicates a single unsigned charac ter.
s
indicates a character string.
%
printf
can be one of the following:
) means to print a %.
command incorrectly, the console returns one of the
following e rror messages:
•printf: Expected numeric argument; invalid string argument found
%
The
<conversion_specification>
expected numeric data in the input
argument, which contained a text string (“hello there”) instea d of a number
(123).
•printf: Format string has more format codes than there are arguments
The <
arguments (<
> string has more con version specifications than the re are input
format
>,. . .,<pN>).
p1
2-32
printf: Invalid format code
•
You entered an invalid conversion specification in the format string (
Example
The followin g example shows a sample
let slot = 2
printf “Slot: %5d\n” $slot
printf
comman d:
%z
).
303563-A Re v 00
record
Command Reference
The
record
command saves to an open file all messages written to the console
terminal. Use this command when you need to capture a snapshot of Technician
Interface output for analysis by Bay Networks Technical Response Center
personnel.
You must open a snapshot file before attempting to capture any Technician
Interface output to that file.
You must close the file
•After capturing the desi red output from the Technici an Inte rface
•Before unmounting the router file system
•Before resetting the router
If you do not follow these instruction s, you can lose the contents of your snapshot
file.
Enter the follo wing command to open a file, and to sa ve console messages to that
file:
record open [-fileonly
creates and opens a snapshot file. The system sends command output and
open
] [
-pause
]
<vol>:<filename>
messages to both the console terminal and the file.
303563-A Rev 00
-fileonly
writes messages only to the file, not to the terminal. This option is used
only within a script, and is otherwise ignored. This option allows a script to write
output to a file. The default is for messages to be written to both the file and the
terminal.
-pause
with the
<vol>
<filename>
immediately places the system in pause mode. You can use this option
-fileonly
option.
is the slot number containing the volume used to store the file.
is the name of the file used to store output from the router’s
T echnician Interface.
2-33
Writing Technician Interface Scripts
Note:
When you designate a snapshot file on an NVFS (flash) file system,
remember that only one snapshot file can be open at a time. If you use other
T echnician Interface commands to write to another file when the snapshot file
is open on the same file syste m, the commands fa il.
You can stop saving messages to a snapshot file temporarily by using the
option with the
record
command.
pause
To change the pause state, enter
record pause [on
on
disables recording .
off
re-enables recording.
off
|
]
To display the pause state, enter
record pause
To close and save the contents of your designated snapshot f ile, enter
record close
By checking the global variable RECORD_STATE, you can determine whether
•The router is acti vely saving messages to your snapshot file
(RECORD_STATE = ON)
•The router has temporarily stopped saving messages to your snapshot file
(RECORD_STATE = PAUSED)
2-34
•The router has uncond itionally stopped saving messages to your snapshot file
(RECORD_STATE = OFF)
303563-A Re v 00
return
Command Reference
You use the
the
command executes, the script interpreter begins executing the
return
command in a subrouti ne to re turn to the call ing rout ine . When
return
instructions on the line following the line containing the
is the name of the script file you want to execute.
are optional input
parameters to the script file. They may be referred to within the script file, as
follows:
-> $1
<p1>
-> $2
<p2>
-> $3
<p3>
2-36
-> $4
<p4>
-> $5
<p5>
-> $6
<p6>
-> $7
<p7>
-> $8
<p8>
-> $9
<p9>
To locate script errors, use the
verbose on
command and then use the
run
command. The Technician Interface displays each line from the file before it
executes the line, enabling you to locate errors easily.
303563-A Re v 00
Command Reference
Note:
the script file name you specify. If you issue the command
The
run
command automatically appends the .bat suffix to the end of
run install
, the
system first looks for a file named install. If it cannot find this file, it looks for
a file named instal l.bat.
The special var iable $# contains the number of parameters entered on the
command line follo wing the script file name. It is set to zero if no parameters are
entered.
303563-A Rev 00
2-37
Writing Technician Interface Scripts
save env
The
save env
command allows you to save the current list of local and global
variable s to a script file.
Syntax
The
save env
save env
<filename>
command has the following syntax:
<filename>
is the name of the file in which you want to store the v ariables.
Example
For example, the following script saves the current list of va riables to the
install.bat file.
save env install.bat
2-38
303563-A Re v 00
setenv
Command Reference
The
setenv
command allows you to assign an ASCII stri ng value or a numeric
value to a va riable in the local environment variable table. When you assign a
value to a variable, you do not type the
before the va riable. If the value contains
$
spaces or tabs, place double quot es (“”) around the value string.
Syntax
The
setenv
setenv
<variable_name>
<variable_value>
command has the following synta x:
<variable_name> <variable_value>
is the name of the variable.
is the value assig ned to the variable.
Example
For example, the following script assigns the value “Good Morning” to the
variable
setenv a “Good Morning”
a.
303563-A Rev 00
2-39
Writing Technician Interface Scripts
source env
The
source env
Interface commands in a Technicia n Interface script file. The
command allows you to read and ex e cute the Technician
source env
command saves (resto res) all local variables when a script ends.
Syntax
The
source env
source env
is the volume storing the scri pt file.
<vol>
<filename>
T o lo cate script errors, use the
command has the following syntax:
<vol>:<filename>
is the name of the script file that contains the variables.
verbose on
command and then use the
source env
command. The Technician Interface displays each line from the file before it
executes the line, enabling you to easily locate errors.
2-40
303563-A Re v 00
sprintf
Command Reference
The
sprintf
command con v erts and formats text , and sa v es the res ult in a s pecif ied
variable for later use.
Syntax
The
sprintf
sprintf
<variable_name>
command has the following syntax:
<variable_name> <format> <p1> <p2> . . . <pN>
is the name of the environment variable where the formatted
string is sav ed.
<format>
is the conversion specification. (See “printf” for information about
conversion specifications.)
<p2> . . . <pN>
If you enter the
is the list of arguments to be formatt ed.
sprintf
command incorrectly, the console returns one of the
following e rror messages:
sprintf: Expected numeric argument; invalid string argument found
•
The
<conversion_specification>
%
expected numeric data in the input
argument, which contained a text string (“hello there”) instea d of a number
(123).
303563-A Rev 00
sprintf: Format string has more format codes than there are arguments
•
The <
> string has more con version specifications than the re are input
format
arguments (<p1>,. . .,<pN>).
sprintf: Invalid format code
•
You entered an invalid conversion specification in the format string (
*ERROR*** Symbol name is greater than 15 characters
•
You specified a variabl e name l o nge r than 15 characters.
*ERROR*** Invalid character “<invalid_character>” in <symbol>
•
You entered an invalid character in the variable name.
**ERROR*** Symbol text is greater than 255 characters
•
The value assig ned to the variable is longer than 255 characters.
).
%z
2-41
Writing Technician Interface Scripts
unsetenv
The
unsetenv
command allows yo u to dele te one or more v a riable s from the loc al
or global environment vari able ta ble. You cannot delete a v ariabl e from the sys tem
environment variable table.
Syntax
The
unsetenv
unsetenv
unsetenv
unsetenv *
unsetenv -l *
unsetenv -g *
unsetenv
unsetenv
<variable_name>
deletes variab les from the local table only.
-l
command has the following syntax:
<variable_name>
<variable_name>,<variable_name>,
<text>
*
<text>
?
is the name of the variable you want to delete.
. . .
2-42
deletes varia bles from the global table only.
-g
deletes all vari ab les from the table you specify. If you do not specify a table, it
*
deletes all v ariables.
matches a single character in the given string position.
?
deletes all variables that begin with the specified text string.
<text>
303563-A Re v 00
Command Reference
Examples
If you enter:The system :
unsetenv slot
unsetenv slot value
unsetenv *
unsetenv -l *
unsetenv -g *
unsetenv ip_*
Deletes the variable
table, depending on the table in which the variable resides.
Deletes the v ariables
or global tab le, depending on the table in which the
variables reside.
Deletes all variables in both the local and glo bal
environment variable tables.
Deletes a ll variables in the lo c a l envir o nm en t var ia ble
table.
Deletes all variables in the global envi ronment variable
table.
Deletes all symbols that begin with
slot
from either the local or the global
slot
and
value
from either the local
ip_
.
303563-A Rev 00
2-43
Writing Technician Interface Scripts
verbose
The
verbose
command allows you to enable the debug trace facility. When you
enable the trace facility, the Technician Interface displays each command read
from the script file before and after its variables have been expanded.
Syntax
The
verbose
verbose [on|off
[
on|off
command has the following syntax:
]
] is on to enable the debug trace f acility or
to disable it.
off
2-44
303563-A Re v 00
To help you create your own scripts, this appe ndix contains three sample scripts:
•Menu script
•FDDI.mnu script
•FDDI.bat script
Menu Script
Appendix A
Sample Scripts
303563-A Rev 00
The followin g example shows a menu script for a Bay Networks router:
:MENU:
on error :MENU:
echo “”
echo “Simple Menu Example”
echo “”
echo “1. Display Time and Date”
echo “2. Display TFTP default volume”
echo “3. Set TFTP default volume”
echo “4. Quit”
echo “”
setenv ans “$<Enter selection: >”
if “$ans ” = “” then; \
goto :MENU:
if $ans = 1 then; \
date ; \
echo “” ; \
goto :MENU:
if $ans = 2 then ;\
let vol=$(wfTftp.wfTftpDefaultVolume.0);\
echo “Tftp Default Volume:$vol”;\
goto :MENU:
if $ans = 3 then ;\
let vol=$<Enter new TFTP Default Value #: >;\
set wfTftp.wfTftpDefaultVolume.0 $vol;\
go to :MENU:
The followin g example shows a protocol script for a Bay Networks router. You
view output from the sc ript by entering script commands (for example,
) at the Tec hnician Interfac e command line, or by using the menu utility. See
fddi
Using Technician Interface Scripts for instructions on entering script commands.
The following script allows you to display information from FDDI MIB objects,
and to enable or disable FDDI.
# @(#)WSCCS k/scripts-fddi.bat 1.11 10/31/95 #
################################################################
#
#Copyright Bay Networks, Inc. 1995
#
#Display FDDI Driver Information
#
################################################################
################################################################
#
# Set up for either using the builtin octetfmt function (7.80 or newer)
# or the gosub (7.70)
#
################################################################
#
# General variable initialization...
setenv cmd “$1”
let cmdlen = strlen(cmd)
if $cmdlen < 3 then ; goto :FI_HELP:
let i = strindex(“show”, cmd)
if $i = 1 then ; goto :FI_SHOW:
let i = strindex(“enable”, cmd)
if $i = 1 then ; goto :FI_ENBL:
let i = strindex(“disable”, cmd)
if $i = 1 then ; goto :FI_DSBL:
# else fall through to the Help screen.
################################################################
#
# Help screen...
#
################################################################
A-4
:FI_HELP:
echo “FDDI Command Script”
echo “-------------------”
echo
echo “This script is not intended to be run directly.”
echo “Please 'run setpath' and then use the following”
echo “commands:”
echo
echo “disable fddi”
echo “enable fddi”
echo “show fddi”
echo
goto :FI_END:
303563-A Re v 00
Sample Scripts
################################################################
#
# Parse for “show” command...
#
################################################################
:FI_SHOW:
if $# = 1 then ; goto :FI_HELP_SHOW:
setenv cmd “$2”
let len = strlen(cmd)
if $len < 3 then ; goto :FI_HELP_SHOW:
let i = strindex(“base”, cmd)
if $i = 1 then ; goto :FI_BASE:
let i = strindex(“alerts”, cmd)
if $i = 1 then ; goto :FI_ALERTS:
let i = strindex(“disabled”, cmd)
if $i = 1 then ; goto :FI_DSBLED:
let i = strindex(“enabled”, cmd)
if $i = 1 then ; goto :FI_ENBLED:
let i = strindex(“stats”, cmd)
if $i = 1 then ; goto :FI_STATS:
303563-A Rev 00
let i = strindex(“receive”, cmd)
if $i = 1 then ; goto :FI_RCV:
let i = strindex(“transmit”, cmd)
if $i = 1 then ; goto :FI_XMIT:
let i = strindex(“system”, cmd)
if $i = 1 then ; goto :FI_SYSTEM:
let i = strindex(“smt”, cmd)
if $i = 1 then ; goto :FI_SMT:
let i = strindex(“mac”, cmd)
if $i = 1 then ; goto :FI_MAC:
let i = strindex(“port”, cmd)
if $i = 1 then ; goto :FI_PORT:
let i = strindex(“sample”, cmd)
if $i = 1 then ; goto :FI_SAMP:
let i = strindex(“hwfilters”, cmd)
if $i = 1 then ; goto :FI_HWF:
let i = strindex(“version”, cmd)
if $i = 1 then ; goto :FI_VER:
A-5
Writing Technician Interface Scripts
:FI_HELP_SHOW:
echo “FDDI Show Command Help”
echo “----------------------”
echo
echo “show fddi <option>”
echo “ Where option is one of the following:”
echo “ ?”
echo “ alerts”
echo “ base [circuit <circuit name>]”
echo “ disabled”
echo “ enabled”
echo “ hwfilters”
echo “ mac [circuit <circuit name>]”
echo “ port”
echo “ receive errors [circuit <circuit name>]”
echo “ sample [<period in seconds>] [circuit <circuit name>]”
echo “ smt [circuit <circuit name>]”
echo “ stats [circuit <circuit name>]”
echo “ system errors [circuit <circuit name>]”
echo “ transmit errors [circuit <circuit name>]”
echo “ version”
goto :FI_END:
################################################################
#
# Base or Module screen...
#
################################################################
:FI_BASE:
A-6
#
# check for circuit name to match on...
#
if $# = 2 then ; goto :FI_BASE_NM:
setenv cmd “$3”
let len = strlen(cmd)
if $len < 3 then ; goto :FI_HELP_SHOW:
let j = strindex(“circuit”, cmd)
if $j != 1 then ; goto :FI_HELP_SHOW:
if $# != 4 then ; goto :FI_HELP_SHOW:
setenv matchcct “$4”
################################################################
#
# Print one line for base/alerts/disabled/enabled screens...
#
################################################################
if $# < 3 then; goto :FI_Tx1:
let cmdlen = strlen(“$3”)
let i = strindex(“errors”, “$3”)
if $i = 1 then ; if $cmdlen >= 3 then ; goto :FI_Tx1:
goto :FI_HELP:
:FI_Tx1:
#
# check for circuit name to match on...
#
if $# <= 3 then ; goto :FI_XMIT_NM:
setenv cmd “$4”
let len = strlen(cmd)
if $len < 3 then ; goto :FI_HELP_SHOW:
let j = strindex(“circuit”, cmd)
if $j != 1 then ; goto :FI_HELP_SHOW:
if $# != 5 then ; goto :FI_HELP_SHOW:
setenv matchcct “$5”
if $# < 3 then; goto :FI_Sy1:
let cmdlen = strlen(“$3”)
let i = strindex(“errors”, “$3”)
if $i = 1 then ; if $cmdlen >= 3 then ; goto :FI_Sy1:
goto :FI_HELP:
:FI_Sy1:
#
# check for circuit name to match on...
#
if $# <= 3 then ; goto :FI_SYS_NM:
setenv cmd “$4”
let len = strlen(cmd)
if $len < 3 then ; goto :FI_HELP_SHOW:
let j = strindex(“circuit”, cmd)
if $j != 1 then ; goto :FI_HELP_SHOW:
if $# != 5 then ; goto :FI_HELP_SHOW:
setenv matchcct “$5”
if $# = 2 then ; goto :FI_SMT_NM:
setenv cmd “$3”
let len = strlen(cmd)
if $len < 3 then ; goto :FI_HELP_SHOW:
let j = strindex(“circuit”, cmd)
if $j != 1 then ; goto :FI_HELP_SHOW:
if $# != 4 then ; goto :FI_HELP_SHOW:
setenv matchcct “$4”
setenv bit0x1 “. . . R ”
setenv bit0x2 “. . R . ”
setenv bit0x3 “. . R R ”
setenv bit0x4 “. R . . ”
setenv bit0x5 “. R . R ”
setenv bit0x6 “. R R . ”
setenv bit0x7 “. R R R ”
setenv bit0x8 “R . . . ”
setenv bit0x9 “R . . R ”
setenv bit0xA “R . R . ”
setenv bit0xB “R . R R ”
setenv bit0xC “R R . . ”
setenv bit0xD “R R . R ”
setenv bit0xE “R R R . ”
setenv bit0xF “R R R R ”
let policy = $(wfFddiEntry.wfFDDISmtConnectionPolicy.${list_[$i]})
303563-A Rev 00
:FI_BIT_LP:
let -h result = ($policy & (0xF << $bit)) >> $bit
setenv flags “${flags}${bit[$result]}”
:FI_NEXT_BIT:
let bit = $bit - 4
if $bit >= 0 then ; goto :FI_BIT_LP:
# Note field size is 32 because flags contains the trailing space.
printf “%32s” “$flags”
let state = $(wfFddiSmtEntry.wfFddiSmtEcmState.${list_[$i]})
if $state = 1 then ; printf “%-8s ” “ByPassed”
if $state = 2 then ; printf “%-8s ” “In”
if $state = 3 then ; printf “%-8s ” “Trace”
A-21
Writing Technician Interface Scripts
if $state = 4 then ; printf “%-8s ” “Leave”
if $state = 5 then ; printf “%-8s ” “Pathtest”
if $state = 6 then ; printf “%-8s ” “Insert”
if $state = 7 then ; printf “%-8s ” “By_Check”
if $state = 8 then ; printf “%-8s ” “Deinsert”
let state = $(wfFddiSmtEntry.wfFddiSmtCfState.${list_[$i]})
if $state = 1 then ; printf “%-8s ” “Isolated”
if $state = 2 then ; printf “%-8s ” “Unknown”
if $state = 3 then ; printf “%-8s ” “Wrap A”
if $state = 4 then ; printf “%-8s ” “Wrap B”
if $state = 5 then ; printf “%-8s ” “Wrap AB”
if $state = 6 then ; printf “%-8s ” “Thru”
if $state = 7 then ; printf “%-8s ” “Local A”
if $state = 8 then ; printf “%-8s ” “Local B”
if $state = 9 then ; printf “%-8s ” “Local AB”
if $state = 10 then ; printf “%-8s ” “Unknown”
if $state = 11 then ; printf “%-8s ” “C Wrap A”
if $state = 12 then ; printf “%-8s ” “C Wrap B”
if $state = 13 then ; printf “%-8s ” “Unknown”
################################################################
#
# MAC screen...
#
################################################################
:FI_MAC:
let i = 1
#
# check for circuit name to match on...
#
if $# = 2 then ; goto :FI_MAC_NM:
setenv cmd “$3”
let len = strlen(cmd)
if $len < 3 then ; goto :FI_HELP_SHOW:
let j = strindex(“circuit”, cmd)
if $j != 1 then ; goto :FI_HELP_SHOW:
if $# != 4 then ; goto :FI_HELP_SHOW:
setenv matchcct “$4”
:FI_MAC_NM:
echo
echo “FDDI Modules MAC Parameters:”
echo “----------------------------”
echo
let tneg = $(wfFddiMacEntry.wfFddiMacTNeg.${list_[$i]}) / 1000000
printf “%4d ” $tneg
let state = $(wfFddiMacEntry.wfFddiMacRmtState.${list_[$i]})
if $state = 1 then ; printf “%-9s ” “Isolated”
if $state = 2 then ; printf “%-9s ” “NonOp”
if $state = 4 then ; printf “%-9s ” “RingOp”
if $state = 8 then ; printf “%-9s ” “Detect”
if $state = 16 then ; printf “%-9s ” “NonOpDup”
if $state = 32 then ; printf “%-9s ” “RingOpDup”
if $state = 64 then ; printf “%-9s ” “Directed”
if $state = 128 then ; printf “%-9s ” “Trace”
on error :FI_PORT_NXT:
if $i > $list_0 then; goto :FOOTER_AND_END:
printf “%4d %4d ” $(wfFddiPortEntry.wfFddiPortSlot.${list_[$i]}) \
$(wfFddiPortEntry.wfFddiPortNode.${list_[$i]})
let port = $(wfFddiPortEntry.wfFddiPortPcType.${list_[$i]})
if $port = 1 then ; printf “%-5s ” “A”
if $port = 2 then ; printf “%-5s ” “B”
if $port = 3 then ; printf “%-5s ” “S”
if $port = 4 then ; printf “%-5s ” “M”
if $port = 5 then ; printf “%-5s ” “None”
let port = $(wfFddiPortEntry.wfFddiPortPcNeighbor.${list_[$i]})
if $port = 1 then ; printf “%-9s ” “A”
if $port = 2 then ; printf “%-9s ” “B”
if $port = 3 then ; printf “%-9s ” “S”
if $port = 4 then ; printf “%-9s ” “M”
if $port = 5 then ; printf “%-9s ” “Unknown”
let port = $(wfFddiPortEntry.wfFddiPortPcmState.${list_[$i]})
if $port = 1 then ; printf “%-9s ” “Off”
if $port = 2 then ; printf “%-9s ” “Break”
if $port = 3 then ; printf “%-9s ” “Trace”
if $port = 4 then ; printf “%-9s ” “Connect”
if $port = 5 then ; printf “%-9s ” “Next”
if $port = 6 then ; printf “%-9s ” “Signal”
if $port = 7 then ; printf “%-9s ” “Join”
if $port = 8 then ; printf “%-9s ” “Verify”
if $port = 9 then ; printf “%-9s ” “Active”
if $port = 10 then ; printf “%-9s ” “Maint”