You are here: 17 Object Triggers > Trigger Variables > How-to > Setting and Receiving Trigger Variables

17.22 Setting and Receiving Trigger Variables

To set and require variables

  1. Create a trigger.
  2. EType=start,AType=exec,Action="/tmp/trigger1.sh"

  3. Use the Sets attribute to set a variable if the trigger succeeds. You can precede the variable with "!" to indicate that the variable should be set if the trigger fails. You can specify more than one variable by separating them with a period.
  4. AType=exec,Action="/tmp/trigger1.sh",EType=start,Sets=!Var1.Var2

    The trigger sets variable Var2 when it succeeds and variable Var1 when it fails.

  5. Set up the recipient trigger(s). Use the Requires attribute to receive the variable(s). Note that preceding the variable with "!" means that the variable must not be set in order for the trigger to fire.
  6. AType=exec,Action="/tmp/trigger1.sh",EType=start,Sets=!Var1.Var2
    AType=exec,Action="/tmp/trigger2.sh",EType=start,Requires=Var1
    AType=exec,Action="/tmp/trigger3.sh",EType=start,Requires=Var2

    The second trigger will launch if Var1 has been set (the first trigger failed), and the third trigger will launch if Var2 is set (the first trigger succeeded).

  7. Refine the requirement with comparisons.
    1. Use the following format:
      <varID>[:<type>[:<varVal>]]
    2. Change <varID> to the variable name.
    3. Use any of the comparisons found on the Trigger Variable Comparison Types page in place of <type>:
    4. Set the value that the variable will be compared against.
    5. AType=exec,Action="/tmp/trigger2.sh",EType=start,Requires=Var1:eq:45
      AType=exec,Action="/tmp/trigger3.sh",EType=start,Requires=Var2:ne:failure1

      The first trigger fires if Var1 exists and has a value of 45. The second trigger fires if Var2 does not have a string value of failure1.

© 2016 Adaptive Computing