infor.com
concierge
infor u
developer portal
documentation central
customer center
Posts
Categories
Groups
ERPs
CSD
FSM/HRT
LN
M3
Syteline/ CSI
Hubs
Developer
Healthcare
Hospitality
Public Sector
Onboarding
Release Center
CloudSuites
Aerospace & Defense (LN)
Automotive (LN)
Chemicals (M3)
Corporate (FSM/HRT)
Distribution (Sx.e/CSD)
Distribution Enterprise (M3)
Engineering & Construction (LN)
Fashion (M3)
Food & Beverage (M3)
Healthcare (FSM/HRT)
Industrial (Syteline/CSI)
Industrial Enterprise (LN)
Manufacturing (M3)
Public Sector (FSM/HRT)
Solutions
Supply Chain Management (SCM)
Human Capital Management (HCM)
Events
Groups
User Groups
Your Groups
About
Email Community Support
Infor News
Migrated Forums
Home
Clovertech
Clovertech Archive
Cloverleaf
Execute 'setsite' in TCL script
System
Originally posted by Devika Agarwal
Can we execute 'setsite' in Tcl script?
Find more posts tagged with
Clovertech
Comments
Keith McLeod
I believe this is what I last used when providing the $site value
if ![catch {netcfgLoad} err] {
NCFG:ChangeSite $site
netcfgLoad
}
Jim Kosloskey
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 [list y 1 Y 1 n 0 N 0] $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
}
System
Originally posted by Devika Agarwal
Thanks Keith and Jim for sharing your scripts. I was finally able to setsite in Tcl. However, I am unable to stop a thread in site B from site A (script in site A) even after I changed site to site B in Tcl. Is there something I am missing?
Devika
david_barr
Where is your TCL code executing? Is this in a TPS proc in thread in Site A?
System
Originally posted by Devika Agarwal
It is a TPS proc and I am running it through server command-line using 'tcl'. The proc isn't in any threads.
david_barr
I think you're better off just using exec with the correct command to stop the thread.
set res [catch { exec ksh -c "setsite site_b; hcicmd -p process_b1 -c 'thread_b1 pstop'" } output]
echo res = $res
echo output = $output
david_barr
How about this?
set res [catch { exec hcicmd -s site_b -p process_b1 -c "thread_b1 pstop" } output]
echo res = $res
echo output = $output
System
Originally posted by Devika Agarwal
That worked. Thanks David. I really appreciate your help.