alerts using tcl

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf alerts using tcl

  • Creator
    Topic
  • #49409
    Gary Atkinson
    Participant

      Using “exec” to execute tcl scripts under the action tab, do you have to provide the absolute path to script? Also what is better to use in your script:

      Code:

      !#/bin/sh
              #
              exec hcitcl “$0” “$@”

      OR
              !#/usr/bin/env hcitcl

      Thanks!

    Viewing 6 reply threads
    • Author
      Replies
      • #61844
        Russ Ross
        Participant

          I choose to use “approach-1” in my standalone TCL scripts as follows

          Code:

          #!/usr/bin/ksh
          # this line to escape the next line from the tcl interpreter
          exec hcitcl “$0” “$@”

          rather than “approach-2” as follows

          Code:

          !#/usr/bin/env hcitcl

          Both might be fine if you never do a cloverleaf upgrade.

          Also this is the first time I’ve seen approach-2, so other comments will be of interest.

          I know approach-1 will dynamically handle picking the right version of hcitcl during the upgrade phase when you might be running multiple versions of cloverleaf.

          I do not know if using the environment to select hcitcl (approach-2) will correctly handle this upgrade overlap phase.

          My suspicion is that approach-2 might only pick the most recent version of cloverleaf environment, esepcially if its behavior is influenced by /etc/environment.

          I would be curious about what determines which hcitcl interpreter approach-2 picks; it will need to pick 2 different versions when multiple versions of Cloverleaf are being used for it to be advantageous.

          Russ Ross
          RussRoss318@gmail.com

        • #61845
          Gary Atkinson
          Participant

            Ok, I thought of another question.  Lets say I have a procedure with some arguments I want to execute if the alert is triggered.  Can I use “exec” and use the proc name w/ args or do I have to use “Tcl”? And yes this is probably a dumb question, but I was reading that you should be very cautious of using “tcl” and should used “exec” instead 😉

          • #61846
            Russ Ross
            Participant

              Here is an example of using the exec in an alert ACTION to invoke a standalone KSH script with command line args.

              {VALUE lastr} {SOURCE ib_pathnet_8015} {MODE actual} {WITH 1} {COMP {>= 900}} {FOR {nmin 10}} {WINDOW {* * 7-18 * * 1-5}} {HOST {}} {ACTION {{exec {recycle_thread_alert.ksh   weekday__ib_pathnet_8015    ‘LIS Admins – recycle Pathnet queue manager HF1 because it has not sent cloverleaf ib_pathnet_8015 anything for at least ten minutes’    ib_pathnet_8015   ib_pathnet_8015}}}}

              Granted it is using KSH and not TCL but I fully expect both to work.

              In this sample entry above the ACTION part calls KSH script recycle_thread_alert.ksh and passes the following 4 command line args

              weekday__ib_pathnet_8015

              ‘LIS Admins – recycle Pathnet queue manager HF1 because it has not sent cloverleaf ib_pathnet_8015 anything for at least ten minutes’

              ib_pathnet_8015

              ib_pathnet_8015

              Russ Ross
              RussRoss318@gmail.com

            • #61847
              Gary Atkinson
              Participant

                What directory does Cloverleaf pick up the script for execution?  The reason I ask is I do not see a path.

              • #61848
                Charlie Bursell
                Participant

                  Any directory in the path.  However it is best for maintenance purposes to put things like this in the $HCISITEDIR/scripts directory.  There is a path created for this directory when you setsite but the directory is not created by default.  Simply create the directory.

                  As for running your Tcl procs, I see no reason to exec hcitcl or anything like that.  If you are on Unix, simply write a stan-alone Tcl proc, make it executable, and put it in the path ($HCISITEDIR/scripts).  If on Windoze, simply put an htc suffix and put in the path.

                  The simpliest, generic method to set up a stand-alone Tcl procedure on Unix is to put the following at the begiing of the script.  Remeber that on Unix or Windoze, argv will contain a list of arguments while argc will be the number of arguments.  So from Alerts, simply exec the scrip with it’s arguments.

                  This is not brain surgery here  ðŸ˜‰

                  #!/bin/sh

                  # If not running Cloverleaf 5.x, you will probably have to change the next # line to point to the full path for Tcl.

                  # The following line is seen as a continued comment by Tcl

                  exec $QUOVADX_INSTALL_DIR/integrator/bin/hcitcl “$0″ ${1+”$@”}

                  proc myproc (argv argc) {

                        .

                        .

                  }

                  myproc $argv $argc

                • #61849
                  Russ Ross
                  Participant

                    In my case I created a site for global objects called mda_global.

                    The script you are asking about called recycle_thread_alert.ksh happens to be a global object because any site that has alerts turned on will use it.

                    The beauty of creating a global site is that Cloverleaf upgrades will treat it like a any other site and do any needed conversions.

                    So back to your question about where is it in the path.

                    I modified the path so every site environment has an extra scripts directory; one for the global scripts.

                    By default there is also a path to a site specific scripts directory if you decide to create one.

                    Let’s look at the the prod_lis site as an example

                    When I run my parse_path.ksh script (note $FPATH is a sneaky part of the path that is hidden and often overlooked)

                    Code:

                    #!/usr/bin/ksh

                    echo $PATH:$FPATH | awk -F: ‘{for (i=1;i<=NF;i++) print $i}'

                    here is what I get as output for my path

                    /quovadx/qdx5.2/integrator/prod_lis/bin

                    /quovadx/qdx5.2/integrator/prod_lis/scripts

                    /quovadx/qdx5.2/integrator/bin

                    /quovadx/qdx5.2/integrator/mda_global/scripts

                    /quovadx/qdx5.2/integrator/contrib

                    /quovadx/qdx5.2/integrator/sbin

                    /quovadx/qdx5.2/integrator/dbms/bin

                    /quovadx/qdx5.2/integrator/tcl/bin

                    /quovadx/qdx5.2/integrator/clgui/bin

                    /quovadx/qdx5.2/integrator/clgui/java/bin

                    /quovadx/qdx5.2/integrator/usercmds

                    /usr/bin

                    /etc

                    /usr/sbin

                    /usr/ucb

                    /home/hci/bin

                    /usr/bin/X11

                    /sbin

                    .

                    /usr/local/bin

                    /usr/local/scripts /quovadx/qdx5.2/integrator/kshlib

                    The way I choose to accomplish this was by modifying hcisetenv by adding the bolded line below in the right place

                           $ENV{ ‘PATH’       } = join($pathSepChar, (“$root/bin”,

                                                                       “$root/mda_global/scripts”,

                                                                       “$root/contrib”,

                                                                       “$hcibin”,

                                                                       “$root/dbms/bin”,

                                                                       “$root/tcl/bin”,

                                                                       “$root/clgui/bin”,

                                                                       “$root/clgui/java/bin”,

                                                                       “$usercmd”,

                                                                       $ENV{‘PATH’}));

                    I’m not sure if you really wanted to know about my pathing because like Charlie says there is more than one way to skin a cat.

                    Deciding where to put something and what to call the paths is not hard and fast but making a decision and creating standards for everyone at your facility to follow is one of the best things you can do.

                    If you are asking about the pathing because you can’t locate my script, then my answer will not be of any help because I wrote the script.

                    Refer to this URL for a copy of the script if that is what you are looking for

                    https://usspvlclovertch2.infor.com/viewtopic.php?t=1806” class=”bbcode_url”>https://usspvlclovertch2.infor.com/viewtopic.php?t=1806

                    Russ Ross
                    RussRoss318@gmail.com

                  • #61850
                    Gary Atkinson
                    Participant

                      Russ-

                      Thanks for all this information.  I did find out that someone before I came along created directory called “cscripts”, which was not in the path.  I have adjusted the PATH.  We have a very small engine, with only one site, so this should be ok for us.  I’ve only been using Unix and Cloverleaf for that matter for a few months, so I learn something new each day. 8)

                      Gary

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