XMC TCP Script - got Exception error "null"
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
‎05-02-2019 11:00 AM
Hi,
i write this kind of TCL Script to configure easily the switche uplink ports with a new VLAN:
This is the resulting CLI Output if i run the script:
i check my script several times but i cannot recognize the error.
i the past if i get such error there is a mistake in defining IF THEN Statements or i forget a paranthesis ...
i start XMC debuging - does not help to find the error ...
i write this kind of TCL Script to configure easily the switche uplink ports with a new VLAN:
code:
# @DetailDescriptionStart
#############################################################################
# Modify Uplink VLAN Configuration on EXOS Switch - device-based
#
# Script : EXOS UPL VLAN Modification
# Revision : 1.0
# History #1 : make script running
# Last Updated : 02.05.2019
# Author : M.Nees (BELL)
#
#####################################################################
#
#######################################################################################
# @DetailDescriptionEnd
#######################################################################################
# @ScriptDescription "Device-based Uplink VLAN Configuration for EXOS Switches"
# @SectionStart (description = VLAN Informationen)
#
# @VariableFieldLabel (description = "Uplink Kennzeichner",
# type = String,
# scope = global,
#)
set var UPL_name UPLINK
# @VariableFieldLabel (description = "Neues VLAN (max. 1 VLAN) - VLAN-ID",
# type = String,
# scope = global,
#)
set var VLAN_ID ""
# @VariableFieldLabel (description = "VLAN Mode: Untagged (UT) oder Tagged (T)",
# type = String,
# validValues=[UT,T],
# scope = global,
#)
set var VLAN_mode "T"
# @MetaDataEnd
###########################################################
# Get the list of Uplink Ports
# Define Variable a fix start-point
set var UPL_port "x"
echo "****************************************************"
echo "*List device port information: "
CLI show ports description
echo "****************************************************"
regexp ".*${UPL_name}.*" ${CLI.OUT} isUPL_LABELexists
IF ([info exists isUPL_LABELexists]) THEN
puts "Some Ports are labeled as $UPL_name"
# Add new VLAN additionally to Uplink Port
CLI create vlan $VLAN_id
# Lets try to catch port number of uplink port
set content $CLI_OUT
set records [split $content "\n"]
foreach line $records {
IF ([regexp ".*${UPL_name}.*" $line match]) THEN
set UPL_port [lindex $line 0]
# Add new VLAN addiotionally to Uplink Port
IF ([string equal $VLAN_mode "UT"]) THEN
CLI conf vlan $VLAN_id add $UPL_port untagged
ELSE
CLI conf vlan $VLAN_id add $UPL_port tagged
ENDIF
ENDIF
}
ENDIF
This is the resulting CLI Output if i run the script:
code:
EMC User: root
EMC User Domain:
CLI Login: cli-admin
TEST-SW 10.1.1.210 05/02/2019 12:26:47 PM at 12:26:47 PM
****************************************************
*List device port information:
TEST-SW.1 # show ports description
Port Display String Description String
===== ==================== ==================================================
1
2
3
4
5
6 UPLINK UPLINK
7
8
9
10
11
12
13
14
15
16
===== ==================== ==================================================
TEST-SW.2 #
****************************************************
Some Ports are labeled as UPLINK
javax.script.ScriptException:
*** Script Error ***
null
-> if { [info exists isUPL_LABELexists] } {
i check my script several times but i cannot recognize the error.
i the past if i get such error there is a mistake in defining IF THEN Statements or i forget a paranthesis ...
i start XMC debuging - does not help to find the error ...
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
‎05-09-2019 07:00 AM
Additionally there are some other experiences:
+ XMC uses not a native tcl engine - it uses TclJava (tcljava.sourceforge.net)
+ notepad++ can be used for TCL syntax highlighting
+ tcl for windows (active state tcl = activeTCL) can be used for better syntax checking -
howexer XMC syntax for Loops "IF (condition) THEN then_action ELSE else_action ENDIF" is not possible and have to be rewritten to TCL native style "if { condition } { then_action } else | elseif { else_action }"
+ temporary printing of variables values during the script run will help to check what's good and what's bad ...
+ XMC uses not a native tcl engine - it uses TclJava (tcljava.sourceforge.net)
+ notepad++ can be used for TCL syntax highlighting
+ tcl for windows (active state tcl = activeTCL) can be used for better syntax checking -
howexer XMC syntax for Loops "IF (condition) THEN then_action ELSE else_action ENDIF" is not possible and have to be rewritten to TCL native style "if { condition } { then_action } else | elseif { else_action }"
+ temporary printing of variables values during the script run will help to check what's good and what's bad ...
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
‎05-09-2019 06:51 AM
Thanks to excellence GTAC Support.
He show me several point why are problematic or errorness:
+ Variables are case-sensitive - i used $VLAN_id and $VLAN_ID - that a difference
+ i use $CLI.OUT which contains the last EXOS command output - later in the script i used $CLI_OUT - this could be working because build-in script uses this too, but should be also corrected
+ i had a logical error that $CLI.OUT should be filled with "show ports description" but i copy a "create vlan $VLAN_id" before which overwrite this variable with wrong input.
I correct this issues and the script is running now.
He show me several point why are problematic or errorness:
+ Variables are case-sensitive - i used $VLAN_id and $VLAN_ID - that a difference
+ i use $CLI.OUT which contains the last EXOS command output - later in the script i used $CLI_OUT - this could be working because build-in script uses this too, but should be also corrected
+ i had a logical error that $CLI.OUT should be filled with "show ports description" but i copy a "create vlan $VLAN_id" before which overwrite this variable with wrong input.
I correct this issues and the script is running now.
