Here s a module I used to change dynamically to another site:
################################################################################
# Name: oth_switch_site
# Purpose: Switch to a Cloverleaf Site
# UPoC type: other
# Args: upvar 1 argument
# arg4tcl – the additional argument block
# which the Site Name (sans pathing)
# is provided.
# A DEBUG parameter is also provided.
# Author: Jim Kosloskey
# Date-written: 06/13/2013
#
#**************************************************************************************************************
#* C O D E A U D I T *
#*_____________________________________________________________________________*
#*Date I-Catcher Description *
#*———- ———- ———————————————–*
#*06/13/2013 Procedure conceived.
#*
#*______________________________________________________________________________*
#*
#*______________________________________________________________________________*
#**************************************************************************************************************
#
# Notes:
# This procedure is intended to be invoked from another Tcl procedure.
# The invoking procedure needs to deliver the following arguments:
# arg4tcl – an argument block consisting of a keyed list with the following values:
# SITENM – This key has a value associated with it which is the site name
# to which we want to switch.
# DEBUG – This key has a value associated with it which tells this proc to
# produce displayed values of variables and actions within this
# proc for the purposes of debug. A value of Y or y will turn debug
# on – any other value will turn debug off.
# The arg4tcl block would have this look: {{SITENM “mysite”} {DEBUG “y”}}
#
################################################################################
#
proc oth_switch_site { } {
global HciConnName ;#Get the connection name
global HciSite
global env
#
# Check the HCI globals to see if they exist
# They won’t exist if we are not invoked while within Cloverleaf
# So we need to null them so they do exist and we can have a proc
# which works within Cloverleaf and outside Cloverleaf
#
if {![info exists HciConnName]} {
variable HciConnName “not Cloverleaf”
}
if {![info exists HciSite]} {
variable HciSite “not Cloverleaf”
}
# Upvar the variables from the invoker
upvar arg4tcl arg4tcl
set sitename “”
set mydebug_sw “N”
set ret_cd “”
set err “”
set module “OTH_SWITCH_SITE v1.0:”
# Check for DEBUG The debug_sw variable will contain the provided arg
set ret_cd [keylget arg4tcl DEBUG mydebug_sw]
if {$ret_cd} { ;# Found the argument
} else { ;# Couldn’t find the argument
echo “$HciConnName $module ERROR!!: Cannot locate DEBUG!”
return
}
set mydebug_sw [string map
$mydebug_sw] ;#Change to logic sw
#Get SITENM
set ret_cd [keylget arg4tcl SITENM sitename]
if {$ret_cd} { ;# Found the argument
} else { ;# Couldn’t find the argument
echo “$HciConnName $module ERROR!!: Cannot locate SITENM!”
return
}
#If debug – display received arguments
if {$mydebug_sw} { ;#Debug on?
echo “$HciConnName $module: argument block = >$arg4tcl<”
echo “$HciConnName $module: SITENM = >$sitename<”
echo “$HciConnName $module: DEBUG = >$mydebug_sw<”
echo “$HciConnName $module: —- Switching to Site named >$sitename<.”
}
#Do the switch
set ret_cd [catch {eval [exec ${::env(HCIROOT)}/sbin/hcisetenv -site tcl $sitename]} err]
if {$ret_cd} {
echo “$module Switch to site >$sitename< failed…”
echo “$module with error >$err<. Aborting!”
return 0
}
return 1
}
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.