Using of parameters in IF statemens of action scripts

(imported topic written by hermann_huebler@at.ibm.com)

I want to use a parameter in an IF statement of an action script in a TEM 8.2 environment. So my first approach was to code it like that:

if {exists file {parameter “tempDir”}/endAllQmgrs.sh}}

… some action

endif

however this script fails and in the logfile I get the following error: “Command failed (Relevance substitution error.) if {exists file {parameter “tempDir”}/endAllQmgrs.sh} (fixlet 136)”.

As per the relevance guide this is working as designed however I’d like to know if there is a workaround for that?

(imported comment written by Lee Wei)

Just a guess as I did not test the following.

  • You cannot have embedded substitution parameters
  • Also the “file” relevance should usually be: file “/tmp/file” in quotes

So I would try:

{exists file “(parameter “tempDir”)/endAllQmgrs.sh”}

Lee Wei

(imported comment written by hermann_huebler@at.ibm.com)

Thanks a lot for your reply here. Here is the code what I’ve tested now:

parameter “tempDir” = “{if (exists variable “TEMP” of environment) then variable “TEMP” of environment as string else if (exists variable “TMP” of environment) then variable “TMP” of environment as string else”/tmp"}"

if {exists file “{parameter “tempDir”}/test.txt”}

delete {parameter “tempDir”}/test.txt"

endif

but this again fails with:

Command failed (Relevance substitution error.) if {exists file “{parameter “tempDir”}/test.txt”}

no matter if I use “{}” or “()” the error is the same.

Is there really no way to implement some sort of flexibility here?

(imported comment written by BX8S_Hamish_O_Hara)

You can’t nest {} with each other you need to use () for nested relevance statements.

parameter “tempDir” = “{if (exists variable “TEMP” of environment) then value of variable “TEMP” of environment as string else if (exists variable “TMP” of environment) then value of variable “TMP” of environment as string else”/tmp"}"

if {exists file (parameter “tempDir” & “/test.txt”)}

delete “{parameter “tempDir”}/test.txt”

endif

It seems to work when you concatenate the parameter and string constant within the (), it doesn’t work when you try and do the following

if {exists file (parameter “tempDir”) & “/test.txt”}

endif

1 Like