Alert whenever a thread receives a message

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Alert whenever a thread receives a message

  • Creator
    Topic
  • #52871
    Karen Newlove
    Participant

      I am having a problem setting up an alert in Cloverleaf 5.6.

      I am not familiar with alerts to begin with, so bear with me  ðŸ˜• .

      I want to set up an alert to execute a csript whenever a particular thread receives a message.

      I feel i have tried everything, but cannot get it to do what I need 🙄

      Anyone have a suggestion?

      I have also tried to make a tcl that does an exec, but with no luck (not any experience with tcl exec either).

    Viewing 4 reply threads
    • Author
      Replies
      • #75739
        Robert Kersemakers
        Participant

          Hi Karen,

          If you want to execute your script every time a particular thread receives a messages, then alerts are not the way to go.

          You should insert a tcl-proc into the ‘TPS Inbound Data’ of that thread. The tcl-proc will look something like this:

          Code:

          ######################################################################
          # Name: execute_script
          # Purpose: Execute script.
          # UPoC type: tps
          # Args: tps keyedlist containing the following keys:
          #       MODE    run mode (”start”, “run” or “time”)
          #       MSGID   message handle
          #       ARGS    user-supplied arguments:
          #              
          #
          # Returns: tps disposition list:
          #          
          #

          proc execute_script { args } {
             keylget args MODE mode               ;# Fetch mode

             set dispList {} ;# Nothing to return

             switch -exact — $mode {
                 start {
                     # Perform special init functions
             # N.B.: there may or may not be a MSGID key in args
                 }

                 run {
             # ‘run’ mode always has a MSGID; fetch and process it
                     keylget args MSGID mh

                     exec

                     lappend dispList “CONTINUE $mh”
                       
                 }

          shutdown {
             # Doing some clean-up work
          }

                 default {
             error “Unknown mode ‘$mode’ in execute_script”
                 }
             }

             return $dispList
          }

          where is the path and the name of the script.

          That should do the trick. Just be careful: if the script can return an error, then you need to take care of that in the tcl-proc.

          Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

        • #75740
          Karen Newlove
          Participant

            Hi Robert,

            Thanks for your reply.

            I had tried to use a TCL on the inbound, but had a problem with the exec.

            I tried with:

            set tmp [ exec C:\Data\vbs\SendMail3.vbs ]

            Then I get:

            C:DatavbsSendMail3.vbs(24, 1) (null): The system cannot find the file specified.

            Then I tried with:

            set tmp [ exec cscript C:\Data\vbs\SendMail3.vbs ]

            Same result. When I try the following:

            set tmp [ exec wscript C:\Data\vbs\SendMail3.vbs ]

            Everything omes to a halt, but not error, and if I pass another msg it is not beeing handled, and I can not stop the thread.

            I take it that has to do with the SendMail3.vbs, but that is a different matter.

          • #75741
            Robert Kersemakers
            Participant

              Hi Karen,

              Hmmm… I’m not very ‘fluent’ on Windows. But from the ‘exec’ TCL manual pages I found this:

              Quote:

              Two or more forward or backward slashes in a row in a path refer to a network path.

              So please try

              Code:

              set tmp [ exec c:/Data/vbs/vSendMail3.vbs ]

              Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

            • #75742
              Karen Newlove
              Participant

                Hi Robert,

                Thanks for the info, but unfortunatly 1 forward slash instead of 2 backward slashes in the path does not change the behaviour.

                Thanks for trying  ðŸ™‚

              • #75743
                Davin Studer
                Participant

                  This is what I have done in our Windows environment.

                  proc myProc {} {

                     set cmd “[exec cmd /C C:\Foo\Bar.exe]”

                     if {[catch $cmd result]} {

                         echo “ERROR: An error occurred running “$cmd”.”

                         echo ”     Result was: $result”

                     }

                  }

                  Since you are trying to execute a .vbs file you may need to actually run wscript and pass the .vbs file as a command line parameter to wscript rather than try to run it explicitly.

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