Executing cloverleaf commands from TCL scrip

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Executing cloverleaf commands from TCL scrip

  • Creator
    Topic
  • #55444
    Tahir Shaikh
    Participant

      Hi,

      What is the syntax to use cloverleaf commands from TCL script

      e.g. cloverleaf provides hciprocstatus commands which can be run successfully from Remote commands window. How can I execute the same from Inbound/Upoc TCL

      Thanks,

      Tahir

    Viewing 6 reply threads
    • Author
      Replies
      • #85358
        Jim Kosloskey
        Participant

          Use exec or system command.

          Read the man page on both and decide.

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

        • #85359
          David Barr
          Participant

            You can also use “open” if you want to read the output in your script.

            set fp [open “|hciprocstatus” r]

          • #85360
            Jeff Dinsmore
            Participant

              You can do something like this to execute a command, check status of the execution, and capture the result.

              Code:

              set processName epic_adt_ib

              if { [catch {exec hciprocstatus -p $processName} procStat] } {
               
               puts “ERROR:n $procStat”
               
              } else {

               puts “SUCCESS:n $procStat”

              }

              If this is executed after I’ve set site to epic_ib, the result looks like this:

              Quote:

              SUCCESS:

              Process         State    Message




              epic_adt_ib     running  Started at Thu Jun 22 15:51:51 2017

              If I execute something that generates an error – like a command that doesn’t exist – it hits the “ERROR” condition:

              Code:

              if { [catch {exec hciXprocstatus -p $processName} procStat] } {
               # error
               puts “ERROR:n $procStat”
               
              } else {

               puts “SUCCESS:n $procStat”

              }

              … and generates this:

              Quote:

              ERROR:

              couldn’t execute “hciXprocstatus”: no such file or directory

              Jeff Dinsmore
              Chesapeake Regional Healthcare

            • #85361
              Tahir Shaikh
              Participant

                Thank you everybody.

                But for all the commands I get below error

                ‘couldn’t execute “hciprocstatus”: no such file or directory’

              • #85362
                Jeff Dinsmore
                Participant

                  This must be run from an hcitcl prompt on your Cloverleaf server.  

                  The path to $env(HCIROOT)/bin must be in your “PATH” environment variable to execute hciprocstatus without a full path to the executable.

                  On a Unix/Linux, you can list the elements of the PATH environment variable like this:

                  Code:

                  foreach p [split $env(PATH) “:”] { puts “p= $p” }

                  On Windows, just change the colon to semicolon like this:

                  Code:

                  foreach p [split $env(PATH) “;”] { puts “p= $p” }

                  Assuming you’re running some sort of Unix/Linux variant, you can check existence of the executable from an hcitcl prompt (on your Cloverleaf server) like this:

                  Code:

                  file exists “[file join $env(HCIROOT) bin hciprocstatus]”

                  I’m not running Cloverleaf on Windows, but I assume the command file has a .exe extension. So, the following will probably work on Windows.

                  Code:

                  file exists “[file join $env(HCIROOT) bin hciprocstatus.exe]”

                  Jeff Dinsmore
                  Chesapeake Regional Healthcare

                • #85363
                  David Barr
                  Participant

                    Maybe your PATH isn’t set up to run the command. You could try this from your script (before the hciprocstatus):

                    eval [exec $::env(CL_INSTALL_DIR)/integrator/sbin/hcisetenv -root tcl]

                  • #85364
                    Ron Pinter
                    Participant

                      Tahir,

                          One of the ways that we do this is to set up a shell script to execute the tclscript.  Here is the contents of what we have in the shell script:

                      #!/usr/bin/ksh

                      setroot /hci/cis6.1/integrator

                      setsite scc

                      /sites/cron_files/tclscripts/cksndtime scc

                      Then in the cksndtime tclscript we have the following:

                      #!/usr/bin/env tcl

                      .

                      .

                      exec — hcicmd -p $process -c “$thread prestart 30”

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