if statement in action script looking for string in file

I have tried several variations of the below in my action script and cannot get it to work. I am looking for a string of text within a file and if found, exit with RC 1. I continue to either get a relevance substitution error or it seems as if BigFix does not even do anything with the if statement and will just complete. Any suggestions?

parameter “Agent_Installation_File” = “{ names of files whose(name of it starts with “installation” AND name of it ends with “.log”) of folder “/opt/dynatrace/oneagent/log/installer” }”

if {(exists file (parameter “Agent_Installation_File”) of folder “/opt/dynatrace/oneagent/log/installer” whose (exists line whose (it contains “Dynatrace OneAgent failed to connect to Dynatrace Cluster Node”) of it))}
exit 1
endif

had to mimic what you have on windows…

parameter "Agent_Installation_File" = "{(names of it) of files whose (name of it as string starts with "installation" and name of it as string ends with ".log") of folder "c:\windows\temp\test"}"


if {exists file (parameter "Agent_Installation_File" of action) of folder "c:\windows\temp\test" AND exists line whose (it contains "Dynatrace OneAgent failed to connect to Dynatrace Cluster Node" of it) of file (parameter "Agent_Installation_File" of action) of folder "c:\windows\temp\test"}
run cmd /c mkdir "c:\windows\temp\test\hey_it_worked"
endif

The notes for the parameter keyword at developer.bigfix.com state:

The saved parameter value is always a string.

If there is any error in evaluating the relevance expression to create the parameter, then the parameter will not be set. If the relevance expression results in multiple values then, then the command fails.

Your relevance will evaluate to a type of plural string, so the parameter will not be set.

2 Likes

Thanks so much! I was able to get it working with this. Seems I was missing the of action.