Searching for characters within a file name

(imported topic written by jfschafer)

I need to make automatic groups that groups systems that have a file with certain unique characters in the file name itself.

For example, If the file is named IEM-COMPANYABC-GROUP1.txt and is located in the default Bigfix install directory, I want machines to join a group if the file name itself contains “COMPANYABC” anywhere in the file name.

This is what I am thinking but want to run it by all you experts if its the best way

exists (names of files of parent folder of client) whose (it contains “IEM-COMPANYABC”)

I also need to make sure this works on all OS’s. (Windows, Linux Mac etc). I’ve not seen non-windows systems evaluate to the
parent folder of client
statements yet but windows systems populate almost immediately. Is there something different I should use to substitute the Bigfix agent parent folder substitution?

Thanks!

(imported comment written by NivS)

Just tested
parent folder of client
on an AIX server and it evalutes as expected to the client install directory.

Unless you’re sure of the file name’s case I’d add something to address it, such as:

exists (names of files of parent folder of client) whose (it as lowercase contains “iem-companyabc”)

(imported comment written by jfschafer)

It doesn’t seem to work on Centos / Redhat etc. We don’t have any AIX so I can’t test on that. What I did is make a straight relevance that looked directly for the folder and file itself using this and all Linux systems join the group.

exists

file

"/var/opt/BESClient/IEM-COMPANYABC.txt

I then changed the relevance to use exists (names of files of parent folder of client) whose (it contains “IEM-COMPANYABC”) instead and the Linux machines fell out of the group almost immediately. What’s strange is Windows boxes have no issues with this relevance.

I even tried adding “as lowercase” and “as string” to see if that helped and it didn’t (but Windows systems joined).

exists (names of files of parent folder of client as lowercase as string) whose (itcontains “IEM-COMPANYABC” as lowercase as string)

(imported comment written by jgstew)

This is not significantly different, but it is more specific. It may also be slightly faster to evaluate.

exists files whose((it starts with “IEM” AND it ends with “.TXT” AND it contains “COMPANYABC”) of (name of it as uppercase)) of parent folder of client

(imported comment written by jfschafer)

Ok I’ve definitely confirmed Linux does not like the whole parent folder of client thing. I made a group with the standard exists file “var/opt…” relevance and all Linux machines populated. I replaced with:

exists

((names

of

files

of

parent folder

of

client)

as

lowercase)

whose

(
it

contains

“IEM-COMPANYABC”

as
lowercase)

all Linux machines left the folder and all windows machines populated. What gives??? Yes, I’ve verified the file exists…

(imported comment written by Trailsuender)

Many thanks for the thread here, can also use it very well! (Y)

And ouch: “Ok I’ve definitely confirmed Linux does not like the whole parent folder of client thing”. (I assume it’s a problem of the IEM Linux client and not a origin Linux problem.)

OK, it make no sense to check Windows registry entries in Unix systems, but I really do not understand this differences between Windows and Unix clients caused by no reason.

(imported comment written by MattPeterson)

The problem with client folder in UNIX is the client folder is evaluted to the path were QNA exist (/opt/BESClient/bin) instead of /var/opt/BESClient. You should be able to use parent folder of (parent folder of (client folder of current site)) which will evaluate to /var/opt/BESClient and will also work properly in Windows.

(imported comment written by jfschafer)

I wasn’t using the fixlet debugger when testing this on unix (mostly because I don’t have a linux system myself). I used it on live systems so the debugger path doesn’t apply. (I saw how it did this with windows so I simply put the file in the path of the debugger agent to test).

I tried your relevance and it doesn’t work. I put it in the debugger so I could at least see if it evaluated with no errors and got a “singular expression refers to a non-existent object.” Copy and Paste from debugger:

q: parent folder of (parent folder of (client folder of current site))

E: Singular expression refers to nonexistent object.

What I’m looking here is one single statement that will find a text file on Mac, Windows, Linux and systems that finds the characters “companynameABC” in a file name that’s located in the parent folder of the Bigfix install location. Is that possible?

(imported comment written by MattPeterson)

The statment will not work in debugger because there is not a current site. I’ve used that statment in actions/relevance from the console and have had success.

(imported comment written by jfschafer)

I don’t care if it works in debugger or not because that’s not where I ultimately need it to work. Actually it does work in debugger as long as you put the file in the debugger’s “agent” folder. ie, in windows: C:\Program Files (x86)\BigFix Enterprise\BES Console\QnA

Bottom Line (in real world agent location, not debugger):

This works works in Windows:

exists (names of files of parent folder of client) whose (it contains “Company ABC”)

This does not work in Linux:

exists (names of files of parent folder of client) whose (it contains “CompanyABC”)

This works in Linux:

exists (names of files of folder “/var/opt/BESClient/”) whose (it contains “CompanyABC”)

This does not work in Mac:

exists (names of files of folder “/var/opt/BESClient/”) whose (it contains “CompanyABC”)

This does not work in Mac either:

exists (names of files of folder “/Library/Application Support/BigFix/BES Agent/”) whose (it contains “CompanyABC”)

I’d like to have 1 single statement that looks for this file in all OS’s. What am I doing wrong??? Yes, I know I can add “as lowercase” but I checked the case sensitivity in the file and the file is perfect. Just need to get this to work.

(imported comment written by jfschafer)

Just thought of something since my last post. I’ll try this and let you know if it works:

exists

files

whose

(name

of

it

as

lowercase

contains

“COMPANYABC”
)

of

folder (pathname

of

parent folder

of

Client)

(imported comment written by MattPeterson)

I don’t think you understood my post. The statement I posted will work for Windows AND UNIX in actions or analysis, but it will NOT work from debugger.

parent folder of (parent folder of (client folder of current site))

This will evaluate to the path of BESClient folder in any OS.

Client folder, or client, in Unix, I think always evaulates to /opt/BESClient/, even in actions/analysis, which is why you that isn’t working for you.