setroot and setsite in a tcl proc for windows

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf setroot and setsite in a tcl proc for windows

  • Creator
    Topic
  • #51421
    Jason Garrant
    Participant

      Hi,

      I am looking for some information on how to change the site in a tcl proc.  basically I have tried multiple incarnations of the the code below:

      catch {exec cmd /c call setroot $root $site} execResponse

      echo “Response: $execResponse”

      I have tried using -clear, before this, also tried setsite as well, and setsite with -clear.  All come back with no response.  When I do showroot it always comes back with the site I am running the proc from.  

      I am trying to do this, because I am setting up a uPoC protocol thread, that calls this proc, to cycle and delete SMAT and Log files.  I need to change the site because the following lines are only working for the site the thread is currently running in:

      catch { exec — hcicmdnt -p $process -c “. output_cycle” } execResponse

      catch { exec — hcicmdnt -p $processName -c “$threadName save_cycle in” } execResponse

      catch { exec — hcicmdnt -p $processName -c “$threadName save_cycle out” } execResponse

      Thanks in advance,

      Jay

    Viewing 11 reply threads
    • Author
      Replies
      • #70212

        You need to use eval. Here’s an example.

        Code:

        global HciRoot
        set debug 0
        set hciSite [lindex $argv 0]
        set date [clock format [clock seconds] -format %Y%m%d%H%M%S]
        set archDir /data/dbdump/error

        # Set up the environment for Cloverleaf commands
        eval [exec $HciRoot/sbin/hcisetenv -root tcl $HciRoot $hciSite]

        # Get the number of lines in the error database. Ignore the header and footer (8 lines).
        catch { exec hcidbdump -e -U [random 999999] | wc -l } numLines
        set numLines [expr $numLines – 8]

        -- Max Drown (Infor)

      • #70213
        Jason Garrant
        Participant

          Hi Max,

          It’s saying there is no such file or directory.  I followed the path, and it is there, but it is still coming back with the error.

        • #70214

          Do you have the script header in place? Something like “#!/hci/quovadx/qdx5.6/integrator/bin/tcl”?

          -- Max Drown (Infor)

        • #70215

          This is how we call that particular script from cron:

          Code:

          03 01 * * * . ~/.profile.cron; /hci/quovadx/qdx5.6/integrator/sitebni/iig/bin/phs2idx_orderNum_purge.tcl

          Here’s ~/.profile.cron

          Code:

          export HOST=bhciigp
          export CL_INSTALL_DIR=/hci/quovadx/qdx5.6
          export HOSTNAME=bhciigp.boone.org

          eval `${CL_INSTALL_DIR}/integrator/sbin/hcisetenv -root ksh $*`

          -- Max Drown (Infor)

        • #70216
          Mark Thompson
          Participant

            Hi Max,

            Running 6.1.2 on AIX.  Attempting to change site from met_wrk to s1_wrk:

            Code:


            $ hcitcl
            hcitcl>echo $HciSite
            met_wrk
            hcitcl>eval [exec $HciRoot/sbin/hcisetenv -root tcl $HciRoot s1_wrk]
            /hci/wrk/cis6.1/integrator/s1_wrk/exec/databases/rdm.taf
            hcitcl>echo $HciSite
            met_wrk

            Doesn’t appear to change the site.

            - Mark Thompson
            HealthPartners

          • #70217
            Keith McLeod
            Participant

              You may want to try some of this code to help change sites within tcl .

              if  ![catch {netcfgLoad} err] {

                    NCFG:ChangeSite $sitedir

                    netcfgLoad

              }

            • #70218
              Jim Kosloskey
              Participant

                Here is what I have used:

                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

                   }

                email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

              • #70219
                Charlie Bursell
                Participant

                  Jim, Max

                  I used to do it this way but it does not work anymore.  I complained about it before I left.

                  I think the best method now is to use the Cloverleaf library call like stated by Keith.

                • #70220
                  Donna Bailey
                  Participant

                    Just getting a new script running on windows for cycle save(from fellow clovertecher)….I have a section with:

                    global env

                    #######################################

                    #  Pull site & root from environment  #

                    #######################################

                       set WrkDir [setHciDirs]

                       set site $env(HCISITE)

                       set rootdir $env(HCIROOT)

                    echo “HCISITE=$site  HCIROOT=$rootdir”

                    Not sure if that helps..this tcl is being called from a bat script…

                    Donna

                    Donna Bailey
                    Tele: 315-729-3805
                    dbailey@microstar.health
                    Micro Star Inc.

                  • #70221
                    Jim Kosloskey
                    Participant

                      Thanks Charlie.

                      I checked the release notes for 6.1 through 6.2 and did not see any mention regarding this being changed.

                      So in my opinion this is a bug.  Especially since it affects code already in place at some clients.

                      I would report it to Infor but I do not have access to Xtreme.

                      Anyone else who agrees this is a bug who does have access to Xtreme might report it as such.

                      At least to see what Infor’s explanation as to why this no longer functions.

                      email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

                    • #70222
                      Robert Kersemakers
                      Participant

                        A colleague of mine dug into this when we first migrated from CL5.5 to CL6.0. We now have these lines at the beginning of scripts called by cron:

                        Code:

                        # load function for execution in cron
                        FPATH=${CL_INSTALL_DIR}/integrator/kshlib; export FPATH
                               . $FPATH/setroot
                               . $FPATH/setsite

                        On further inspection: we execute a script first when calling from cron:

                        Code:

                        55 23 * * * /home/hci/sethcienv daily_housekeeping_cloverleaf > /dev/null 2>&1

                        The ‘sethcienv’ checks whether the cluster is running on that server; if so then the linux-profile and CL-profile are executed:

                        Code:

                        # Controleren of /prod/cloverleaf/sites60 bestaat
                        if [[ -d /prod/cloverleaf/sites60 ]]
                        then
                          . /etc/profile
                          . /home/hci/.profile
                         # script uitvoeren
                         echo “+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++”
                         $*
                        fi
                        exit 0

                        This may help some people here.

                        Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

                      • #70223
                        Steve Williams
                        Participant

                          I’m converting an old AIX script to TCL (portable to the Windows Server platform) on Clvf v6.1. I tested both Jim’s posted code and Keith’s posted code and here’s what I found on my WinServer 2012 environment.

                          The older code now generates a file not found error. I played around with it but could not get it to work. I can run it directly from the cmdline using the full path name, but from within the hcitcl environemnt it’s lost somehow.

                          The newer code posted by Keith, using NCFG:ChangeSite, worked right out of the box.

                          Disclaimer: Your mileage may vary…

                      Viewing 11 reply threads
                      • The forum ‘Cloverleaf’ is closed to new topics and replies.